Prompt word security reinforcement method and device for large model agent, equipment and medium
By conducting risk assessment and security reinforcement on the prompt words of the large-model intelligent agent, and generating security-reinforced system prompt words, the problem of intelligent agent jailbreaking behavior is solved, and the security of the intelligent agent and the accuracy of information processing are improved.
Patent Information
- Application Number
- CN202510725360.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-12
AI Technical Summary
Existing technologies cannot effectively restrict the jailbreaking behavior of intelligent agents. Users can control intelligent agents to perform unexpected operations by inducing questions and answers. Traditional solutions become ineffective after the model security capabilities are enhanced.
By obtaining the initial system prompt words of the large model intelligent agent, determining the risk assessment information, and generating a second system prompt word with security reinforcement based on the risk assessment information and security constraint information, it ensures that the intelligent agent follows the security constraints when processing requests.
It achieves security protection for intelligent agents, improves the confidence and accuracy of information processing, and prevents jailbreaking and unexpected operations.
Smart Images

Figure CN120632858A_ABST
Abstract
Description
Technical Field
[0001] The exemplary embodiments of the present disclosure generally relate to the field of computers, and more particularly to a method, apparatus, device, and medium for enhancing security of prompt words of a large model intelligent agent. Background Art
[0002] With the advancement of computing, agent interaction technology has become a key research area in artificial intelligence. Prompts play a crucial role in the interaction between agents and users. Prompts can include system prompts and user prompts. System prompts can define the agent's behavior rules, role positioning, output format, and more, while user prompts can be processing requests or questions entered by the user. Summary of the Invention
[0003] In a first aspect of the present disclosure, a method for securing prompt words for a large-model intelligent agent is provided. The method comprises: obtaining an initial first system prompt word for the large-model intelligent agent; determining risk assessment information corresponding to the first system prompt word, the risk assessment information indicating at least one risk present in the first system prompt word; and determining a second system prompt word for the intelligent agent based on the risk assessment information, the first system prompt word, and security constraint information, so that the intelligent agent processes a received processing request based on the second system prompt word.
[0004] In a second aspect of the present disclosure, a device for security reinforcement of prompt words for a large-model intelligent agent is provided. The device includes: an acquisition module configured to acquire an initial first system prompt word of the intelligent agent based on the large model; a first determination module configured to determine risk assessment information corresponding to the first system prompt word, the risk assessment information indicating at least one risk present in the first system prompt word; and a second determination module configured to determine a second system prompt word for the intelligent agent based on the risk assessment information, the first system prompt word, and security constraint information, so that the intelligent agent processes a received processing request based on the second system prompt word.
[0005] In a third aspect of the present disclosure, an electronic device is provided. The device includes at least one processing unit; and at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit. When executed by the at least one processing unit, the instructions cause the device to perform the method of the first aspect.
[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and the computer program can be executed by a processor to implement the method of the first aspect.
[0007] It should be understood that the content described in this summary section is not intended to limit the key features or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0009] Figure 1 A schematic diagram illustrating an example environment in which embodiments of the present disclosure can be implemented;
[0010] Figure 2 A flowchart illustrating a process of security reinforcement of prompt words for a large model agent according to some embodiments of the present disclosure is shown;
[0011] Figure 3 A process flow chart of system prompt word reinforcement according to some embodiments of the present disclosure is shown;
[0012] Figure 4 A schematic structural block diagram of an apparatus for security reinforcement of prompt words for a large model intelligent agent according to certain embodiments of the present disclosure is shown;
[0013] Figure 5 A block diagram of an electronic device capable of implementing various embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0014] The following describes embodiments of the present disclosure in more detail 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 limited to the embodiments described herein. Rather, 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 for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0015] It should be noted that the titles of any section / subsection provided herein are not limiting. Various embodiments are described throughout this document, and any type of embodiment may be included under any section / subsection. Furthermore, the embodiments described in any section / subsection may be combined in any manner with any other embodiments described in the same section / subsection and / or in different sections / subsections.
[0016] 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 be included below. The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may be included below.
[0017] The embodiments of the present disclosure may involve user data, data acquisition and / or use, etc. These aspects shall comply with the corresponding laws, regulations and relevant provisions. In the embodiments of the present disclosure, all data collection, acquisition, processing, processing, forwarding, use, etc. are carried out on the premise that the user is aware of and confirms them. Accordingly, when implementing the various embodiments of the present disclosure, the types, scope of use, and usage scenarios of the data or information that may be involved should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with the relevant laws and regulations. The specific notification and / or authorization method may vary according to the actual situation and application scenario, and the scope of the present disclosure is not limited in this respect.
[0018] If this specification and the solutions in the examples involve the processing of personal information, such processing will be done only with a legitimate basis (such as with the consent of the subject of personal information or as necessary for the performance of a contract) and only within the prescribed or agreed scope. A user's refusal to process personal information other than that required for basic functions will not affect the user's use of basic functions.
[0019] Traditionally, some solutions exist to address some security issues encountered during interactions between users and agents. For example, rule-based constraint solutions such as keyword matching and regular expression matching can be used to identify and intercept unsafe user input. Another example is the ability to determine the safety of user input and the agent's response based on classification models. Furthermore, when training models associated with the agent, security alignment data can be injected to fine-tune and reinforce the model, ensuring the security of the agent's responses.
[0020] However, these traditional solutions are ineffective in preventing jailbreaking attempts at the agent level. For example, if an agent is designed to perform data query services through a plug-in, users might be able to manipulate the agent to perform data modification operations through induced questions and answers. Furthermore, as the security capabilities of the model itself improve, users can use multiple rounds of induced questions to gradually deviate from the agent's original intent. Without the induced questions themselves being overtly malicious, traditional or content-based security solutions may become ineffective.
[0021] Embodiments of the present disclosure propose a solution for securing the prompt words of a large-model intelligent agent. According to this solution, an initial first system prompt word can be obtained for the large-model intelligent agent. Furthermore, risk assessment information corresponding to the first system prompt word can be determined, where the risk assessment information indicates at least one risk present in the first system prompt word. Furthermore, based on the risk assessment information, the first system prompt word, and security constraint information, a second system prompt word can be determined for the intelligent agent, so that the intelligent agent processes a received processing request based on the second system prompt word.
[0022] Based on this approach, the embodiments of the present disclosure can perform security reinforcement on the first system prompt words based on the risk assessment information and security constraint information present in the first system prompt words, so that the intelligent body can process requests based on the second system prompt words obtained after security reinforcement, effectively realizing security protection for the intelligent body and improving the confidence and accuracy of the intelligent body in information processing.
[0023] Sample Environment
[0024] Figure 1 1 shows a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. Figure 1 As shown, example environment 100 may include electronic device 110 .
[0025] In this example environment 100, electronic device 110 can perform security hardening on a first system prompt to obtain a second, hardened system prompt. In some embodiments, an agent 120 connected to electronic device 110 can process requests based on this second system prompt. This second system prompt can define information such as the agent's role, responsibilities, and scope of authority. Prompts can also be referred to as prompt items, prompt information, and so on.
[0026] In some embodiments, the agent 120 can process the processing request input by the user using the large model 130. The large model can be deployed on the electronic device 110, or on other devices or servers, which will not be described in detail here.
[0027] In some embodiments, the electronic device 110 can be any type of mobile terminal, fixed terminal or portable terminal with a display device, including a mobile phone, desktop computer, laptop computer, notebook computer, netbook computer, tablet computer, media computer, multimedia tablet, PDA, portable game terminal, VR / AR device, personal communication system (PCS) device, personal navigation device, personal digital assistant (PDA), audio / video player, digital camera / camcorder, positioning device, television receiver, radio broadcast receiver, e-book device, game device or any combination of the foregoing, including accessories and peripherals of these devices or any combination thereof. In some embodiments, the electronic device 110 can also support any type of interface for the target user (such as "wearable" circuit, etc.).
[0028] The electronic device 110 may also be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks, and big data and artificial intelligence platforms. The electronic device 110 may include, for example, a computing system / server, such as a mainframe, an edge computing node, a computing device in a cloud environment, and the like.
[0029] It should be understood that the structure and function of the various elements in the environment 100 are described for illustrative purposes only and do not imply any limitation on the scope of the present disclosure.
[0030] Some example embodiments of the present disclosure will be described below with continued reference to the accompanying drawings.
[0031] Example Process
[0032] Figure 2 FIG2 is a flowchart showing a process 200 for security reinforcement of a large model agent according to some embodiments of the present disclosure. The process 200 may be implemented at the electronic device 110. Figure 1 Process 200 is described.
[0033] In block 210 , the electronic device 110 obtains an initial first system prompt word of an agent based on a large model.
[0034] In some embodiments, the large model is any appropriate machine learning model with a large number of parameters, which can be configured to handle any appropriate complex task. For example, in the embodiments of the present disclosure, the large model can be a large language model (LLM), a large model can also be a visual large model, an audio large model, or a multimodal large model. The multimodal large model can process multiple different types of data, such as multimodal data such as text, images, and audio.
[0035] In some embodiments, the intelligent agent 120 is a system or entity that can perceive the environment and make decisions, or make decisions and take actions to achieve a specific goal or task. In the industry, intelligent agents are also called agents. In some embodiments, the intelligent agent can use one or more large models to drive its interaction with the user, and the interaction can be any appropriate interaction. As an example, the intelligent agent can use the large model to generate a response content for the processing request input by the user based on the processing request input.
[0036] In some embodiments, the first system prompt words may include initial and non-security-reinforced system prompt words such as the role definition, functional scope, and processing authority of the agent 120.
[0037] In block 220 , the electronic device 110 determines risk assessment information corresponding to the first system prompt word, where the risk assessment information indicates at least one risk present in the first system prompt word.
[0038] In some embodiments, the risk assessment information may indicate at least one risk in the first system prompt word, which may cause the system prompt word corresponding to the intelligent agent 120 to be tampered with, or may cause the response content of the intelligent agent 120 to be out of bounds, etc.
[0039] In some embodiments, the at least one risk may include, but is not limited to, a first risk, a second risk, a third risk, a fourth risk, a fifth risk, etc. These risks may correspond to different levels of insecurity.
[0040] The first risk can be manifested by a lack of behavioral constraints on the agent in the first system prompt. For example, the first system prompt fails to clearly define the agent's output permissions, resulting in a lack of behavioral constraints on the agent. For example, the first system prompt could include "Please answer all user questions," which would result in the agent's behavior being unsafely constrained, potentially leading to the output of responses that exceed the agent's output permissions.
[0041] The second risk may be that the first system prompt does not clearly define the scope of permissions for agent 120, which may lead to agent 120 abusing permissions, such as performing unauthorized operations. For example, if the first system prompt is "The agent can help users manage their accounts," then because the first system prompt does not specify the specific account management operations that agent 120 can perform, agent 120 may be tricked into performing unauthorized management operations, such as resetting passwords or modifying account settings.
[0042] Regarding the third risk, it can indicate that the first system prompt word does not clearly define the processing logic of agent 120, which may cause the behavior of agent 120 to be unpredictable or bypassed. As an example, if the first system prompt word is "Agent 120 should provide helpful suggestions," the vague definition of "helpful" in the first system prompt word may cause agent 120 to provide potentially unsafe suggestions without clear guidance. As another example, if the first system prompt word is "Only provide legal suggestions," the lack of specific judgment criteria will lead to ambiguous processing logic of agent 120.
[0043] The fourth risk may indicate that the first system prompt includes information that supports reverse engineering, potentially allowing other users to exploit sensitive information. For example, if the first system prompt is "Use #REFUND_CODE to initiate a refund," the prompt contains sensitive information, "#REFUND_CODE," which indicates the internal refund processing code. This code could potentially be used by users to perform unsafe operations.
[0044] The fifth risk may indicate that the first system prompt word lacks the security constraint associated with the first system prompt word, which may result in the initial prompt word being tampered with or leaked. The security constraint is used to prevent the initial prompt word from being tampered with or leaked.
[0045] It should be noted that, for the first system prompt word, the risk corresponding to the first system prompt word may be one or more.
[0046] In some embodiments, the risk assessment information can indicate which information fragments in the first system prompt word are at risk. That is, in addition to indicating what specific risks exist, the risk assessment information can also indicate the location information of the information fragments containing this or these risks in the first system prompt word.
[0047] In some embodiments, the electronic device 110 may provide a first system prompt word to the first model to obtain risk assessment information. The first model may be any appropriate machine learning model, such as a large model.
[0048] In order to improve the accuracy of risk assessment information, in other embodiments, the electronic device 110 may provide a first system prompt word to the first model, and provide at least one of plug-in description information associated with the agent and knowledge base description information associated with the agent to obtain risk assessment information.
[0049] In some embodiments, the plug-in description information may indicate the functions and uses corresponding to the plug-in associated with the agent 120. The plug-in associated with the agent 120 may be used to expand the capabilities of the agent 120, which may support adding new data processing functions or accessing external services, etc.
[0050] In some embodiments, the knowledge base description information may indicate information such as the structure and function of the knowledge base that the agent 120 can access or rely on. The knowledge base may include any appropriate data that the agent 120 can process or access.
[0051] Taking the server training the first model as an example, the training process of the first model is described below. It should be noted that the first model can also be trained by any appropriate device (such as electronic device 110) other than the server.
[0052] In some embodiments, the server may obtain a sample. This sample may include a negative sample (also referred to as a black sample) and a positive sample (also referred to as a white sample). The positive sample may be a system prompt word indicating that there is no risk, while the negative sample may be a system prompt word indicating that there is risk.
[0053] Furthermore, the server may train the first model based on the sample. Specifically, the server may provide the sample to the first model to determine training risk information associated with the sample, where the training risk information may indicate the risk present in the sample. In some embodiments, the risk present in the sample may include, but is not limited to, at least one of the following:
[0054] First risk, second risk, third risk, fourth risk, fifth risk, and so on.
[0055] Furthermore, the server may train the first model based on a comparison of the training risk information and the labeled risk information of the sample. The labeled risk information may indicate the labeling risk corresponding to the pre-labeled sample, and the labeling risk may include, but is not limited to, at least one of the following: a first risk, a second risk, a third risk, a fourth risk, a fifth risk, and so on.
[0056] Specifically, the server may determine the first loss value based on the training risk information, the labeling risk information, and a predetermined loss function. The loss function may be any appropriate function, such as a cross-entropy function, etc. Further, the server may train the first model based on the first loss value until a predetermined training completion condition is met to obtain the trained first model. The predetermined training completion condition may be any appropriate condition, such as the first loss value reaching a minimum value, or the training duration reaching a predetermined duration, etc., which will not be elaborated here.
[0057] In order to improve security robustness, this application can introduce an adversarial training mechanism to generate more hidden risk samples or add a certain risk based on non-risk samples.
[0058] In some embodiments, the electronic device 110 may obtain an initial negative sample and an initial positive sample. The initial negative sample is an initial, unprocessed, negative system prompt word indicating a risk. The initial positive sample is an initial, unprocessed, positive system prompt word indicating no risk.
[0059] Furthermore, the electronic device 110 may provide the initial negative sample to the second model to obtain a negative sample. The second model may be any appropriate machine learning model, such as a large model. The negative sample is a sample obtained by slightly weakening the significant vulnerability risk and enhancing the concealment of the initial negative sample. The risk level of the negative sample is lower than that of the initial negative sample. As an example, if the initial negative sample is "prohibit answering any questions unrelated to financial knowledge", the negative sample may be "try to ensure that the answers are related to financial knowledge."
[0060] In some embodiments, electronic device 110 may provide the initial positive sample to the second model to obtain a positive sample. A positive sample is obtained by enhancing the vulnerability risk of the initial positive sample. The risk level of the positive sample is higher than the risk level of the initial positive sample. As an example, electronic device 110 may utilize the second model to remove some security behavior constraints based on the initial positive sample to obtain a positive sample.
[0061] In some embodiments, the electronic device 110 may provide a first guide word to the second model to guide the second model to generate negative samples based on the initial negative samples. The first guide word may indicate the rules for the second model to generate negative samples based on the initial negative samples, such as perturbation rules, intention rules, etc. Figure 1Perturbation rules can indicate how to slightly weaken significant vulnerability risks and enhance concealment. Specifically, perturbation rules may include but are not limited to: using fuzzy expressions to replace strong constraints, weakening the clarity of risky behaviors, etc. Figure 1 The consistency rule is used to indicate that the intention corresponding to the initial negative sample and the intention corresponding to the negative original need to be consistent. In some embodiments, the first guide word can also indicate the perturbation rule, intention Figure 1 Examples of these rules include consistency rules.
[0062] As an example, an example corresponding to the rule of "using fuzzy expressions to replace strong constraint words" can be to modify the strong constraint word "prohibited" in the initial negative sample into a fuzzy expression such as "preferably avoid" or "not recommended".
[0063] As another example, an example corresponding to the rule of "weakening the clarity of risky behavior" can be to modify the constraint word with clarity such as "delete user data" in the initial negative sample to a word with weakened clarity such as "clean up temporary cache".
[0064] In some embodiments, the electronic device 110 may provide a second guide word to the second model to guide the second model to generate positive samples based on the initial positive samples. The second guide word may indicate the rules for the second model to generate positive samples based on the initial positive samples, such as perturbation rules, intention rules, etc. Figure 1 Consistency rules, etc. Perturbation rules may include but are not limited to: removing or blurring key security constraints, introducing fuzzy permissions, etc. Figure 1 The consistency rule is used to indicate that the intention corresponding to the initial positive sample must be consistent with the intention corresponding to the positive version. The second guide word can also indicate the perturbation rule, intention Figure 1 Examples of these rules include consistency rules.
[0065] As an example, an example corresponding to the rule of "removing or blurring key security constraints" can be changing "prohibiting access to electronic medical records" in the initial positive sample to "only orders can be queried" or "orders and related information can be queried".
[0066] As another example, an example corresponding to the rule of "introducing fuzzy permissions" can be to modify "contact the user for confirmation when condition A is met" in the initial positive sample to "contact the user for confirmation when necessary."
[0067] In block 230 , the electronic device 110 determines a second system prompt word for the agent based on the risk assessment information, the first system prompt word, and the safety constraint information, so that the agent processes the received processing request based on the second system prompt word.
[0068] In order to ensure that the system prompt words of the intelligent agent are not easily modified, and to ensure that the intelligent agent 120 can output a safe response, the electronic device 110 can perform security reinforcement on the first system prompt words corresponding to the intelligent agent 120, and use the prompt words after security reinforcement as the second system prompt words corresponding to the intelligent agent 120.
[0069] In some embodiments, the electronic device 110 may provide risk assessment information, the first system prompt word, and security constraint information to a third model to obtain a second system prompt word. Specifically, the third model may be any appropriate machine learning model, such as a large model. The security constraint information is used to indicate the security measures that need to be applied to the first system prompt word to ensure that the operation of the agent 120 using the security-reinforced second system prompt word complies with predetermined security standards. For example, the first system prompt word may be reinforced by clearly defining the authority boundaries of the agent 120, constraining the output format, and implementing reverse protection to address the risks inherent in the first system prompt word.
[0070] In some embodiments, the electronic device 110 may input a guide word into the third model so that the third model can accurately determine the second system prompt word. The guide word may indicate a specific requirement for adjusting the first system prompt word.
[0071] In some embodiments, the security constraint information may include, but is not limited to, first security constraint information, second security constraint information, third security constraint information, fourth security constraint information, and fifth security constraint information, etc. These security constraints are used to constrain content at different security levels.
[0072] The first security constraint information can be used to constrain the behavior of the agent 120. As an example, the first security constraint information can be used to constrain the format of the content output by the agent 120. For example, the first security constraint information can be used to constrain the content output by the agent 120 to not include sensitive information or to comply with legal regulations.
[0073] The second security constraint information can be used to restrict the scope of permissions corresponding to agent 120, preventing it from performing unauthorized operations. For example, the second security constraint information can instruct agent 120 to only perform authorized operations. For example, authorized operations can be any appropriate operation. For example, account query operations can be set as authorized operations, while data modification operations can be set as unauthorized operations.
[0074] The third safety constraint information can be used to constrain the agent's processing logic, ensuring that the behavior of agent 120 is predictable and cannot be circumvented. If the first system prompt is "agent 120 should provide helpful suggestions," the third safety constraint information can constrain the judgment rules regarding "helpfulness," for example, constraining what situations are helpful to the user.
[0075] The fourth security constraint information can be used to constrain the conversion of information in the first system prompt that supports reverse deduction into information that does not support reverse deduction. As an example, the fourth security constraint information can be used to encrypt or obfuscate information that supports reverse deduction (such as sensitive information).
[0076] The fifth security constraint information may be used to configure security constraints associated with the first system prompt word. For example, the fifth security constraint information may indicate certain security rules or security precautions that prevent the first system prompt word from being tampered with or leaked.
[0077] In some embodiments, these security constraint information may be associated with the at least one risk. A first security constraint may be associated with the first risk, a second security constraint may be associated with the second risk, a third security constraint may be associated with the third risk, a fourth security constraint may be associated with the fourth risk, and a fifth security constraint may be associated with the fifth risk. For each security constraint information, the security constraint information is used to mitigate or eliminate the risk associated with the security constraint information.
[0078] As an example, the electronic device 110 may add first safety constraint information (such as binding corresponding legal provisions) to the first system prompt word in response to determining that there is a first risk in the first system prompt word to constrain the corresponding output content of the intelligent agent 120.
[0079] In order to improve efficiency, in other embodiments, the electronic device 110 can also provide risk assessment information and the first system prompt word to the third model to obtain the second system prompt word, that is, the third model has learned the safety constraint information in advance, and can obtain the second system prompt word directly based on the learned safety constraint information when obtaining the risk assessment information and the first system prompt word.
[0080] Taking the server training the third model as an example, the training process of the third model is explained.
[0081] In some embodiments, the server may obtain a negative prompt word. The negative prompt word is a prompt word indicating the presence of risk. The risk of the negative prompt word may include at least one of the following: a first risk, a second risk, a third risk, a fourth risk, and a fifth risk, etc.
[0082] In some embodiments, this negative prompt word can also be a prompt word obtained based on the second model. It can be a sample obtained by slightly weakening the significant vulnerability risk of the initial negative prompt word using the second model and enhancing its concealment. Specifically, the process of obtaining negative prompt words and negative samples is similar and will not be elaborated here.
[0083] Furthermore, the server may provide the negative prompt word to the third model to obtain the first prompt word.
[0084] In order to retain the core functional intent of the negative prompt word and avoid functional failure caused by excessive security, the server can further train a third model based on the comparison between the first prompt word and the negative prompt word.
[0085] Specifically, the server may determine the first intent similarity between the first prompt word and the negative prompt word. In some embodiments, the server may encode the first prompt word and the negative prompt word based on a predetermined encoding model to obtain a first feature representation corresponding to the first prompt word and a second feature representation corresponding to the negative prompt word. Furthermore, the server may determine the first intent similarity based on the first feature representation and the second feature representation. As an example, the electronic device 110 may determine the first intent similarity based on the cosine similarity corresponding to the first feature representation and the second feature representation.
[0086] Furthermore, the server may determine a loss value based on the first intention similarity.
[0087] As an example, the electronic device 110 may determine the loss value based on the following formula:
[0088] Loss=1-cosine(original_embedding,generated_embedding)
[0089] Among them, Loss is the loss value, original_embedding is the second feature representation, generated_embedding is the first feature representation, and cosine(original_embedding, generated_embedding) is the cosine similarity (first intention similarity) corresponding to original_embedding and generated_embedding.
[0090] As another example, the electronic device 110 may also determine the first sub-loss value based on the first intention similarity. Further, the electronic device 110 may determine the second sub-loss value based on the pre-labeled second prompt word corresponding to the negative prompt word, the first prompt word, and a predetermined loss function, where the second prompt word is a positive prompt word pre-labeled for the negative prompt word. The predetermined loss function may be any appropriate function, such as a cross entropy function, etc., which will not be elaborated here. Further, the electronic device 110 may determine the loss value based on the first sub-loss value and the second sub-loss value. As an example, the electronic device 110 may determine the sum of the first sub-loss value and the second sub-loss value as the loss value.
[0091] Furthermore, the server may train the third model based on the loss value until a predetermined training completion condition is met, thereby obtaining the trained third model. The predetermined training completion condition may be any appropriate condition, such as when the loss value reaches a minimum value or when the training duration reaches a predetermined duration, etc., which will not be elaborated here.
[0092] To further ensure the accuracy of the response of the agent 120, in some embodiments, the electronic device 110 can determine whether the candidate prompt word determined by adjusting the first system prompt word satisfies predetermined verification constraints. As an example, the electronic device 110 can determine whether the candidate prompt word can bypass the corresponding security constraint through synonym replacement or semantic deformation to determine whether the candidate prompt word satisfies the predetermined verification constraint. For example, if the candidate prompt word includes the word "avoid", the electronic device 110 can replace the word "avoid" with "bypass" and determine whether the replaced candidate prompt word can bypass the security constraint related to "avoid".
[0093] As another example, the electronic device 110 may determine whether the security constraints in the candidate prompt word disrupt the original functions of the agent 120 to determine whether the candidate prompt word satisfies the predetermined verification constraints. For example, the electronic device 110 may determine whether the agent 120 applied to the candidate prompt word can still process a compliant processing request, where the compliant processing request can be a request that the agent 120 applied to the first system prompt word can support.
[0094] Furthermore, the electronic device 110 may determine the candidate prompt word as the second system prompt word in response to the candidate prompt word satisfying predetermined verification constraints. As an example, if the candidate prompt word cannot circumvent the corresponding security constraints through synonym replacement or semantic transformation, the electronic device 110 may determine that the candidate prompt word satisfies the predetermined verification constraints; otherwise, the predetermined verification constraints are not satisfied. As another example, if it is determined that the security constraints in the candidate prompt word do not disrupt the original functions of the intelligent agent 120, the electronic device 110 may determine that the candidate prompt word satisfies the predetermined verification constraints; otherwise, the predetermined verification constraints are not satisfied.
[0095] Furthermore, the agent may process the received processing request based on the second system prompt word, and the security constraint information indicates at least one security constraint to be applied to the first system prompt word.
[0096] Figure 3 An example flow chart of system prompt word reinforcement according to some embodiments of the present disclosure is shown. Figure 3 Provide explanation.
[0097] In block 310 , the electronic device 110 performs a risk scan based on the first system prompt word 301 .
[0098] As an example, the electronic device 110 may perform a risk scan on the first system prompt word 301 to obtain risk assessment information.
[0099] In some embodiments, the risk assessment information may indicate at least one risk in the first system prompt word, and this at least one risk may include at least one of the following: risk of lack of behavioral constraints (first risk), authority constraints (second risk), risk related to logical fuzziness (third risk), reverse deduction risk (fourth risk), and risk of prompt word tampering and leakage (fifth risk), etc.
[0100] For the first risk, it can be characterized by the fact that the first system prompt word does not set the corresponding behavioral constraints of the intelligent agent 120. For the second risk, it can be characterized by the fact that the first system prompt word does not clearly define the authority scope of the intelligent agent, such as the problem of abuse of authority of the intelligent agent 120 is not set, which may cause the intelligent agent 120 to perform unauthorized operations. For the third risk, it can be characterized by the fact that the first system prompt word does not define the processing logic of the intelligent agent 120, which may cause the behavior of the intelligent agent 120 to be unpredictable or bypassed. For the fourth risk, it can be characterized by the fact that the first system prompt word includes information that supports reverse deduction, which may cause certain sensitive information to be used by other users. For the fifth risk, it can be characterized by the fact that the unconstrained prompt word definition in the first system prompt word may cause the prompt word to be potentially leaked and tampered with.
[0101] In block 320 , the electronic device 110 utilizes the model to optimize the prompt words.
[0102] In some embodiments, the electronic device 110 may provide the risk assessment information and the first system prompt word 301 to a model (such as the third model) to optimize the first system prompt word 301 .
[0103] As an example, in response to a reverse engineering risk in the first system prompt word 301, the electronic device 110 may encrypt sensitive information in the first system prompt word 301 based on the security constraint library to optimize the first system prompt word 301. The security constraint library includes multiple predetermined security constraints, which are used to indicate security measures that need to be applied to the first system prompt word to ensure that the operation of the intelligent agent 120 using the second system prompt word with security reinforcement complies with predetermined security standards to address the risks in the first system prompt word.
[0104] As another example, in response to a constraint missing risk in the first system prompt word 301 , the electronic device 110 may add a permission boundary to the first system prompt word 301 based on the security constraint library to optimize the first system prompt word 301 .
[0105] As another example, in response to the existence of logical fuzzy risks in the first system prompt word 301 , the electronic device 110 may bind legal clauses to the first system prompt word 301 based on the security constraint library to optimize the first system prompt word 301 .
[0106] In block 330 , the electronic device 110 performs an adversarial test on the optimized prompt word.
[0107] As an example, the electronic device 110 can determine whether the reinforced prompt word can bypass the corresponding security constraints through synonym replacement or semantic deformation to determine whether the reinforced prompt word meets the predetermined verification constraints. As another example, the electronic device 110 can also determine whether the security constraint information in the reinforced prompt word destroys the original function of the intelligent agent 120 to determine whether the reinforced prompt word meets the predetermined verification constraints.
[0108] Furthermore, if the reinforced prompt word cannot bypass the corresponding security constraint through synonym replacement or semantic deformation, and it is determined that the security constraint information in the reinforced prompt word does not destroy the original function of the intelligent agent 120, the electronic device 110 can determine that the adversarial test has passed.
[0109] At block 340 , the electronic device 110 may deploy a reinforcement cue word in response to the adversarial test passing.
[0110] As an example, the electronic device 110 may apply the reinforced prompt words to the agent 120 to reconfigure the agent 120 .
[0111] It should be noted that the training samples used by the various models used in boxes 310 and 320 during the training phase can be generated based on the second model, and the prompt words used in box 330 for adversarial testing can also be generated based on the second model. The second model can be configured to perform predetermined operations on the basis of the initial negative samples to generate more covert negative samples, and to increase a certain risk on the basis of the initial positive samples to generate positive samples. In the box 310 stage, the electronic device 110 can use positive samples and negative samples to train the corresponding model in box 310. In the box 320 stage, the electronic device 110 can use negative samples (negative prompt words) to train the corresponding model in box 320.
[0112] Taking the electronic device 110 determining whether a processing request supports being processed by an agent as an example, the process of determining whether a processing request supports being processed by an agent is explained.
[0113] The electronic device 110 can receive a processing request initiated to the large-model-based agent. The processing request can be any appropriate type of request, such as a text request, a voice request, etc. The processing request can correspond to any appropriate intent associated with the user. For example, the processing request can be "Please help me generate a travel guide for place A." The intent corresponding to this processing request can be the intent to generate a travel guide.
[0114] Furthermore, the electronic device 110 may determine a second intention similarity between the processing request and a plurality of preset reference processing requests. In some embodiments, the plurality of reference requests may be pre-generated hypothetical requests, i.e., they may not be requests actually input by the user, but reference requests that may be input by a simulated user.
[0115] In some embodiments, the multiple reference requests may be any appropriate requests, such as but not limited to positive reference requests and negative reference requests.
[0116] In some embodiments, the intent corresponding to the forward reference request may be within the scope of services that the agent can provide.
[0117] In some embodiments, the scope of services provided by the agent may be generated based on a second system prompt word within the agent.
[0118] In other embodiments, the scope of services provided by the agent can also be generated by at least one of the plug-in description information associated with the agent, the knowledge base description information associated with the agent, the confirmed white sample information associated with the agent, and the second system prompt word.
[0119] The second system prompt word can indicate the role, responsibilities and authority scope of the agent 120, etc., which can help define the functional boundaries and operational limitations of the agent 120. The plug-in description information can indicate the functions and uses corresponding to the plug-ins associated with the agent 120. The plug-ins associated with the agent 120 can be used to expand the capabilities of the agent 120, which can support the addition of new data processing functions or access to external services, etc. The knowledge base description information can indicate information such as the structure and functions of the knowledge base that the agent 120 can access or rely on. This knowledge base can include any appropriate data that the agent 120 can process or access. The confirmed white sample information associated with the agent can be any appropriate information that can assist in understanding and helping to determine the scope of services provided by the agent, such as a confirmed white sample request intended to be within the scope of services provided by the agent.
[0120] In some embodiments, the forward reference request can be a request that meets the preset security constraints, or a business request associated with the business type supported and processed by the agent, etc. Requests that meet the predetermined security constraints can also be called requests that meet white intent (positive intent), where white intent represents normal, legal and non-malicious requests. In some embodiments, the predetermined security constraints can be any appropriate constraints, which can be used to constrain and ensure that the requests processed by the agent 120 do not cause security risks or violate security policies. For example, the predetermined security constraints can constrain the request to not include sensitive information, and can also constrain the request to comply with predetermined legal rules, and can also constrain the request to not contain information that deliberately guides the change of the system prompt words of the agent 120, etc. The business type can be any appropriate type, for example, the agent can support the processing of business types related to knowledge popularization, but cannot process business types related to financial management, etc.
[0121] As an example, if the intelligent agent can only provide security services related to knowledge popularization, then the forward reference request can be a request corresponding to security and knowledge popularization intentions such as "Why does a rainbow appear after the rain?"
[0122] In some embodiments, the intent corresponding to a negative reference request may not be within the scope of the services provided by the agent. In some embodiments, a negative reference request may be a request that does not meet predetermined security constraints, or a service request that is unrelated to the service type supported and processed by the agent, etc. Requests that do not meet predetermined security constraints may be requests that meet black intent (negative intent), where black intent represents requests that may be abnormal, illegal, or have malicious attack intent.
[0123] As an example, if the intelligent agent can only provide security services related to knowledge popularization, then the positive reference request can be "Please help me check the income of user A this year", which corresponds to an unsafe request with non-knowledge popularization intentions.
[0124] In some embodiments, the server may provide the second system prompt word to the trained model to generate the multiple reference processing requests. The trained model may be any appropriate machine learning model, such as a large model, which will not be described in detail here.
[0125] In some embodiments, positive reference requests and negative reference requests can be generated using the first model based on corresponding guide words, respectively. In some embodiments, the server can generate a positive reference request using the first guide word. The first guide word can indicate that the intention of the generated reference request is within the scope of services provided by the intelligent agent. It can also specifically indicate that there is a process for generating a positive reference request and precautions, etc. In some embodiments, the server can generate a negative reference request using the second guide word. The second guide word can indicate that the intention of the generated reference request is not within the scope of services provided by the intelligent agent. As an example, the second guide word can indicate that the generated reference request is negative and there are certain risks, but it will not trigger a request for a predetermined security policy. It can specifically indicate that there is a process for generating a negative reference request (for example, the attack path needs to be considered during the generation process, etc.) and precautions, etc.
[0126] The following describes the process of determining the second similarity:
[0127] In some embodiments, the electronic device 110 may determine a first similarity between the processing request and the forward reference request based on a comparison between the forward reference request and the processing request.
[0128] In some embodiments, the higher the first similarity between the processing request and the forward reference request, the more likely it is that the intention of the processing request is within the scope of the service provided by the agent, and the more likely it is that the agent 120 can support processing this processing request.
[0129] Specifically, the electronic device 110 can determine the first similarity between the processing request and the forward reference request based on the comparison between the forward reference request and the processing request. The forward reference request can be one or more. As an example, if there are multiple forward reference requests, the electronic device 110 can respectively determine the first candidate similarities between these multiple forward reference requests and the processing request. Further, the electronic device 110 can determine the highest value corresponding to the first candidate similarity as the first similarity. For example, if there are 3 forward reference requests, and the first candidate similarities between these 3 forward reference requests and the processing request are 0.7, 0.6, and 0.5 respectively, the electronic device 110 can determine 0.7 as the first similarity.
[0130] Furthermore, the electronic device 110 may determine a second similarity between the processing request and the negative reference request based on a comparison between the negative reference request and the processing request. A higher second similarity between the processing request and the negative reference request indicates a greater likelihood that the intent of the processing request is outside the service scope provided by the agent, and a lower likelihood that the agent 120 can support processing the processing request.
[0131] In some embodiments, the negative reference request may be one or more. As an example, if there are multiple negative reference requests, the electronic device 110 may determine the second candidate similarities between the multiple negative reference requests and the processing request. Furthermore, the electronic device 110 may determine the sum of the second candidate similarities as the second similarity. For example, if there are two negative reference requests, and the second candidate similarities between the two negative reference requests and the processing request are 0.3 and 0.4 respectively, the electronic device 110 may determine the second similarity to be 0.7.
[0132] It should be noted that, in order to avoid data overflow, the electronic device 110 may set the second similarity to be less than a threshold, that is, the sum value corresponding to the second candidate similarities may be less than the threshold, and the threshold may be 1. When the sum value corresponding to the multiple second candidate similarities is greater than the threshold, the multiple second candidate similarities may be normalized, and the sum value of the normalized similarities may be determined as the second similarity.
[0133] In some embodiments, the electronic device 110 may directly determine the second intention similarity between the processing request and the multiple reference processing requests based on the first similarity and the second similarity.
[0134] For example, the electronic device 110 may determine the second intention similarity based on the following formula:
[0135] y1=α×x1-β×x2
[0136] Wherein, y1 is the second intention similarity, x1 is the first similarity, x2 is the second similarity, α and β are predetermined coefficients, which can be set according to requirements.
[0137] In other embodiments, the electronic device 110 determines the business relevance between the processing request and the business scenario description information of the agent 120. As an example, the electronic device 110 may determine the business relevance based on comparing the keywords in the processing request with the keywords in the business scenario description information. As another example, the electronic device 110 may determine the business relevance based on the semantic content corresponding to the processing request and matching it with the business scenario description information. For example, if the processing request involves "returns and exchanges", and the business scenario description information of the agent 120 includes description information related to after-sales service, the electronic device 110 may determine that the business relevance between the processing request and the business scenario description information of the agent is 0.9.
[0138] Furthermore, the electronic device 110 may determine a second intention similarity between the processing request and a plurality of reference processing requests based on the first similarity, the second similarity, and the business relevance.
[0139] For example, the electronic device 110 may determine the second intention similarity based on the following formula:
[0140] y2=α×x1+β×x2-γ×x3
[0141] Where y2 is the matching degree, x1 is the first similarity, x2 is the business relevance, x3 is the third similarity, α, β, and γ are predetermined coefficients that can be set as needed. As an example, α+β=1 can be set (usually α>β, for example, α=0.7, β=0.3), and γ∈[0,0.3] (for example, it can be set to 0.2).
[0142] In some embodiments, when comparing a processing request with a reference processing request, the electronic device 110 may compare the first intention corresponding to the processing request and the second intention of the reference processing request. Further, the electronic device 110 may determine the similarity between the first intention and the second intention. For example, if the processing request is "I need to export order data and unlock administrator privileges", and the similarity between the intent corresponding to the processing request and the intent corresponding to the "data query" in the positive reference request is 0.8, and the similarity between the intent corresponding to the processing request and the intent corresponding to the "authority application" is 0.6, and the similarity between the intent corresponding to the processing request and the intent corresponding to the negative reference request is 0.4, and the similarity between the intent corresponding to the "data export risk" is 0.5, and the business relevance is 0.2, then the similarity between the intent of the processing request and the reference processing request is y2 = 0.7 × 0.8 + 0.3 × 0.2 - 0.2 × 0.9 = 0.44.
[0143] In some embodiments, the electronic device 110 may output information allowing the agent to process the request in response to the second intent similarity satisfying a predetermined condition. The predetermined condition may be any appropriate condition, such as whether the similarity is greater than a predetermined threshold. The predetermined threshold may be any appropriate threshold, such as 0.85, 0.9, etc., which will not be described in detail here.
[0144] Specifically, electronic device 110 can compare the second intent similarity with a predetermined threshold to determine whether the second intent similarity is greater than the predetermined threshold. In some embodiments, electronic device 110 can output information allowing the agent to process the processing request in response to the second intent similarity being greater than the predetermined threshold. Furthermore, agent 120 can process the processing request to generate a response result to the processing request.
[0145] In other embodiments, electronic device 110 may output a warning message in response to the second intent similarity not satisfying a predetermined condition. In some embodiments, electronic device 110 may output a warning message in response to the second intent similarity being less than or equal to a predetermined threshold. In some embodiments, the warning message indicates that agent 120 is not allowed to process the request and instead directly rejects the response. Furthermore, electronic device 110 may also log the request so that the user can review relevant information regarding agent 120's rejection of the response.
[0146] Based on this approach, the embodiments of the present disclosure can perform security reinforcement on the first system prompt words based on the risk assessment information and security constraint information present in the first system prompt words, so that the intelligent body can process requests based on the second system prompt words obtained after security reinforcement, effectively realizing security protection for the intelligent body and improving the confidence and accuracy of the intelligent body in information processing.
[0147] Example devices and equipment
[0148] The embodiments of the present disclosure also provide corresponding devices for implementing the above methods or processes. Figure 4 A schematic block diagram of an apparatus 400 for securing prompt words for a large model agent according to certain embodiments of the present disclosure is shown. Apparatus 400 may be implemented as or included in electronic device 110 as discussed above. The various modules / components in apparatus 400 may be implemented by hardware, software, firmware, or any combination thereof.
[0149] like Figure 4As shown, the device 400 includes an acquisition module 410, which is configured to obtain an initial first system prompt word of an intelligent agent based on a large model; a first determination module 420, which is configured to determine risk assessment information corresponding to the first system prompt word, the risk assessment information indicating at least one risk existing in the first system prompt word; and a second determination module 430, which is configured to determine the second system prompt word of the intelligent agent based on the risk assessment information, the first system prompt word and the safety constraint information, so that the intelligent agent processes the received processing request based on the second system prompt word.
[0150] In some embodiments, the first determination module 420 is further configured to provide the first system prompt word to the first model to obtain risk assessment information.
[0151] In some embodiments, the first determination module 420 is further configured to provide a first system prompt word to the first model, and provide at least one of plug-in description information associated with the agent and knowledge base description information associated with the agent to obtain risk assessment information.
[0152] In some embodiments, the first model is trained based on the following process: based on the sample, training the first model,
[0153] The samples include negative samples and positive samples, and the negative samples and the positive samples are determined based on the following process: obtaining an initial negative sample and an initial positive sample; providing the initial negative sample to a second model to obtain a negative sample, wherein the risk level of the negative sample is lower than the risk level of the initial negative sample; and providing the initial positive sample to the second model to obtain a positive sample, wherein the risk level of the positive sample is higher than the risk level of the initial positive sample.
[0154] In some embodiments, at least one risk includes: a first risk indicating that the first system prompt word lacks behavioral constraints on the intelligent agent; a second risk indicating that the first system prompt word does not clearly define at least part of the scope of authority of the intelligent agent; a third risk indicating that the first system prompt word does not clearly define the processing logic of the intelligent agent; a fourth risk indicating that the first system prompt word includes information supporting reverse deduction; a fifth risk indicating that the first system prompt word lacks security constraints associated with the first system prompt word.
[0155] In some embodiments, the second determination module 420 is further configured to provide the risk assessment information, the first system prompt word, and the safety constraint information to the third model to obtain the second system prompt word.
[0156] In some embodiments, the third model is trained based on the following process: obtaining a negative prompt word; providing the negative prompt word to the third model to obtain a first prompt word; and training the third model based on a comparison of the first prompt word and the negative prompt word.
[0157] In some embodiments, based on the comparison of the first prompt word and the negative prompt word, training the third model includes: determining the first intention similarity of the first prompt word and the negative prompt word; determining the loss value based on the first intention similarity; and training the third model based on the loss value.
[0158] In some embodiments, the security constraint information includes at least one of the following: first security constraint information, used to constrain the behavior of the intelligent agent; second security constraint information, used to constrain the scope of authority corresponding to the intelligent agent; third security constraint information, used to constrain the processing logic of the intelligent agent; fourth security constraint information, used to constrain the conversion of information in the first system prompt word that supports reverse deduction into information that does not support reverse deduction; fifth security constraint information, used to configure security constraints associated with the first system prompt word.
[0159] In some embodiments, the second determination module 420 is further configured to: determine the candidate prompt word determined by adjusting the first system prompt word based on risk assessment information, the first system prompt word and security constraint information; determine whether the candidate prompt word satisfies predetermined verification constraints; and in response to the candidate prompt word satisfying the predetermined verification constraints, determine the candidate prompt word as the second prompt word.
[0160] In some embodiments, whether a processing request is allowed to be processed is determined based on the following process: obtaining a processing request initiated to an intelligent agent; determining a second intention similarity between the processing request and a plurality of preset reference processing requests, wherein the plurality of reference processing requests are generated based on the service scope provided by the intelligent agent, and the service scope provided by the intelligent agent is generated based on a second system prompt word; in response to the second intention similarity satisfying a predetermined condition, outputting information allowing the intelligent agent to process the processing request; and in response to the second intention similarity not satisfying the predetermined condition, outputting an alarm message.
[0161] In some embodiments, the multiple reference processing requests include at least one of the following: a positive reference request, wherein the intention of the positive reference request is within the scope of the service provided by the intelligent agent; a negative reference request, wherein the intention of the negative reference request is not within the scope of the service provided by the intelligent agent.
[0162] In some embodiments, the scope of services provided by the agent is determined based on at least one of the plug-in description information associated with the agent, the knowledge base description information associated with the agent, and the confirmed white sample information associated with the agent.
[0163] In some embodiments, determining the second intention similarity between the processing request and a preset plurality of reference processing requests includes: determining a first similarity between the processing request and the positive reference request based on a comparison between the positive reference request and the processing request; determining a second similarity between the processing request and the negative reference request based on a comparison between the negative reference request and the processing request; and determining a second intention similarity between the processing request and the preset plurality of reference processing requests based on the first similarity and the second similarity.
[0164] The units included in the device 400 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units can be implemented using software and / or firmware, such as machine executable instructions stored on a storage medium. In addition to or as an alternative to machine executable instructions, some or all of the units in the device 400 can be implemented at least in part by one or more hardware logic components. By way of example and not limitation, exemplary types of hardware logic components that can be used include field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0165] Figure 5 1 shows a block diagram of an electronic device 500 in which one or more embodiments of the present disclosure may be implemented. Figure 5 The illustrated electronic device 500 is merely exemplary and should not be construed as limiting the functionality and scope of the embodiments described herein. Figure 5 The electronic device 500 shown can be used to implement Figure 1 An electronic device 110 is shown.
[0166] like Figure 5 As shown, electronic device 500 is in the form of a general electronic device. Components of electronic device 500 may include, but are not limited to, one or more processors or processing units 510, memory 520, storage device 530, one or more communication units 540, one or more input devices 550, and one or more output devices 560. Processing unit 510 may be a real or virtual processor and is capable of performing various processes according to programs stored in memory 520. In a multi-processor system, multiple processing units execute computer-executable instructions in parallel to increase the parallel processing capabilities of electronic device 500.
[0167] The electronic device 500 typically includes a plurality of computer storage media. Such media can be any accessible media that can be obtained by the electronic device 500, including but not limited to volatile and non-volatile media, removable and non-removable media. The memory 520 can be a volatile memory (e.g., a register, a cache, a random access memory (RAM)), a non-volatile memory (e.g., a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof. The storage device 530 can be a removable or non-removable medium and can include a machine-readable medium, such as a flash drive, a disk, or any other medium that can be used to store information and / or data (e.g., training data for training) and can be accessed within the electronic device 500.
[0168] The electronic device 500 may further include additional removable / non-removable, volatile / non-volatile storage media. Figure 5 As shown in FIG, a magnetic disk drive for reading from or writing to a removable, non-volatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, non-volatile optical disk may be provided. In these cases, each drive may be connected to a bus (not shown) by one or more data media interfaces. Memory 520 may include a computer program product 525 having one or more program modules configured to perform various methods or actions of various embodiments of the present disclosure.
[0169] The communication unit 540 enables communication with other electronic devices via a communication medium. Additionally, the functions of the components of the electronic device 500 can be implemented in a single computing cluster or multiple computing machines that can communicate via a communication connection. Thus, the electronic device 500 can operate in a networked environment using a logical connection with one or more other servers, a network personal computer (PC), or another network node.
[0170] Input device 550 may be one or more input devices, such as a mouse, keyboard, or trackball. Output device 560 may be one or more output devices, such as a display, a speaker, or a printer. Electronic device 500 may also communicate with one or more external devices (not shown) via communication unit 540 as needed, such as a storage device, a display device, or the like, with one or more devices that allow a user to interact with electronic device 500, or with any device that allows electronic device 500 to communicate with one or more other electronic devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface (not shown).
[0171] According to an exemplary implementation of the present disclosure, a computer-readable storage medium is provided, on which computer-executable instructions are stored, wherein the computer-executable instructions are executed by a processor to implement the method described above. According to an exemplary implementation of the present disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, and the computer-executable instructions are executed by a processor to implement the method described above.
[0172] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, apparatuses, devices, and computer program products implemented according to the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer-readable program instructions.
[0173] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, such that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.
[0174] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0175] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple implementations of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part for a module, program segment or instruction, and a part for a module, program segment or instruction comprises one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous boxes 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 box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be realized by a special hardware-based system that performs the function or action of the specification, or can be realized by a combination of special hardware and computer instructions.
[0176] While various implementations of the present disclosure have been described above, the foregoing description is intended to be illustrative, not exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is selected to best explain the principles of the implementations, their practical applications, or improvements to existing technologies, or to enable others skilled in the art to understand the various implementations disclosed herein.
Claims
1. A method for reinforcing the security of prompt words for a large-scale intelligent agent, comprising: Obtaining the initial first system prompt word of the agent based on the large model; Determining risk assessment information corresponding to the first system prompt word, where the risk assessment information indicates at least one risk present in the first system prompt word; as well as Based on the risk assessment information, the first system prompt word and the safety constraint information, a second system prompt word of the agent is determined, so that the agent processes the received processing request based on the second system prompt word.
2. The method according to claim 1, wherein determining the risk assessment information corresponding to the first system prompt word comprises: The first system prompt word is provided to a first model to obtain the risk assessment information.
3. The method according to claim 2, wherein providing the first system prompt word to the first model to obtain the risk assessment information comprises: The first system prompt word and at least one of plug-in description information associated with the agent and knowledge base description information associated with the agent are provided to the first model to obtain the risk assessment information.
4. The method of claim 2, wherein the first model is trained based on the following process: Based on the samples, the first model is trained. The samples include negative samples and positive samples, and the negative samples and the positive samples are determined based on the following process: Obtain initial negative samples and initial positive samples; Providing the initial negative sample to a second model to obtain the negative sample, wherein the risk level of the negative sample is lower than the risk level of the initial negative sample; and The initial positive sample is provided to the second model to obtain the positive sample, wherein the risk level of the positive sample is higher than the risk level of the initial positive sample.
5. The method of claim 1 , wherein the at least one risk comprises: A first risk indicates that the first system prompt word lacks behavioral constraints on the agent; A second risk indicates that at least a portion of the scope of authority of the agent is not clearly defined in the first system prompt word; The third risk indicates that the first system prompt word does not clearly define the processing logic of the agent; A fourth risk indicates that the first system prompt word includes information supporting reverse deduction; A fifth risk indicates that the first system prompt word lacks a safety constraint associated with the first system prompt word.
6. The method according to claim 1 , wherein determining the second prompt word of the agent based on the risk assessment information, the first system prompt word, and safety constraint information comprises: The risk assessment information, the first system prompt word, and the safety constraint information are provided to a third model to obtain the second system prompt word.
7. The method of claim 6, wherein the third model is trained based on the following process: Get negative cue words; Providing the negative prompt word to the third model to obtain a first prompt word; as well as The third model is trained based on a comparison between the first prompt word and the negative prompt word.
8. The method according to claim 7, wherein training the third model based on the comparison between the first prompt word and the negative prompt word comprises: Determining a first intention similarity between the first prompt word and the negative prompt word; Determining a loss value based on the first intent similarity; as well as Based on the loss value, the third model is trained.
9. The method according to claim 1, wherein the security constraint information includes at least one of the following: First safety constraint information, used to constrain the behavior of the intelligent agent; Second security constraint information, used to constrain the authority scope corresponding to the agent; third security constraint information, used to constrain the processing logic of the agent; Fourth security constraint information, used to constrain the conversion of information in the first system prompt word that supports reverse deduction into information that does not support reverse deduction; The fifth security constraint information is used to configure the security constraint associated with the first system prompt word.
10. The method of claim 1 , wherein determining the second prompt word for the agent based on the risk assessment information, the first system prompt word, and safety constraint information comprises: determining, based on the risk assessment information, the first system prompt word, and the safety constraint information, to adjust a candidate prompt word determined by the first system prompt word; Determining whether the candidate prompt word satisfies a predetermined verification constraint; as well as In response to the candidate prompt word satisfying the predetermined verification constraint, the candidate prompt word is determined as the second prompt word.
11. The method according to claim 1 , wherein the processing request is determined to be allowed to be processed based on the following process: Obtaining the processing request initiated to the agent; determining a second intention similarity between the processing request and a plurality of preset reference processing requests, wherein the plurality of reference processing requests are generated based on a service scope provided by the agent, and the service scope provided by the agent is generated based on the second system prompt word; In response to the second intention similarity satisfying a predetermined condition, outputting information allowing the agent to process the processing request; as well as In response to the second intention similarity not satisfying the predetermined condition, outputting warning information.
12. The method of claim 11, wherein the plurality of reference processing requests comprises at least one of: a forward reference request, wherein the forward reference request is intended to be within the scope of services provided by the agent; A negative reference request, wherein the intention of the negative reference request is not within the scope of the service provided by the agent.
13. A method according to claim 11, wherein the scope of services provided by the agent is determined based on at least one of the plug-in description information associated with the agent, the knowledge base description information associated with the agent, and the confirmed white sample information associated with the agent.
14. The method according to claim 11, wherein determining the second intention similarity between the processing request and a plurality of preset reference processing requests comprises: determining a first similarity between the processing request and the forward reference request based on a comparison between the forward reference request and the processing request; determining a second similarity between the processing request and the negative reference request based on a comparison between the negative reference request and the processing request; as well as Based on the first similarity and the second similarity, the second intention similarity between the processing request and the plurality of preset reference processing requests is determined.
15. A device for security protection of a large model intelligent agent, comprising: An acquisition module is configured to acquire an initial first system prompt word of the agent based on the large model; a first determining module configured to determine risk assessment information corresponding to the first system prompt word, wherein the risk assessment information indicates at least one risk existing in the first system prompt word; as well as The second determination module is configured to determine a second system prompt word for the agent based on the risk assessment information, the first system prompt word and the safety constraint information, so that the agent processes the received processing request based on the second system prompt word.
16. An electronic device comprising: at least one processing unit; as well as At least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform the method according to any one of claims 1 to 14 when executed by the at least one processing unit.
17. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 14 is implemented.
Citation Information
Cited By
Image processing method and device, computer equipment and storage medium
CN121527596A
