An AI agent instruction compliance risk pre-judgment method and device

CN122903972APending Publication Date: 2026-10-13何旭飞
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610755714.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-28
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0007]本发明提供一种面向AI代理指令的合规风险预判方法及装置,旨在解决现有方案在指令阶段缺乏精细化合规风险预判能力的问题,将合规监控的起点从事中前移至事前

Benefits of technology

[0007]本发明提供一种面向AI代理指令的合规风险预判方法及装置,旨在解决现有方案在指令阶段缺乏精细化合规风险预判能力的问题,将合规监控的起点从事中前移至事前。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

The application discloses a compliance risk pre-judgment method and device for AI agent instructions. After the AI agent generates a task plan and before the operation is executed, the user instruction text and the task plan step text are spliced into a joint input sequence, which is sent to a lightweight pre-training model based on a multi-head attention mechanism for coding. The model outputs a risk category probability distribution and an attention heat map, and identifies high-risk steps that need to be focused on from the task plan steps. The application moves the starting point of compliance monitoring from behavior detection during the task to pre-instruction judgment, and can identify potential risks and guide the optimal allocation of subsequent monitoring resources before the agent performs any operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of AI agent security and compliance risk detection technology, and can be widely applied to compliance risk prediction methods and devices based on lightweight multi-head attention models for AI agent instructions. Background Technology

[0002] When an AI agent executes a task, it first receives the user's natural language instructions, then autonomously generates a task plan and breaks it down into a series of operational steps. Traditional security solutions typically monitor the AI ​​agent only after it begins execution—that is, intercepting the action when or after it occurs. This post-event detection model has a blind spot: between the user issuing the instruction and the AI ​​agent executing the first step, the system does not conduct a compliance risk assessment of the instruction itself or the task plan generated by the agent.

[0003] If potential risks can be anticipated during the instruction phase, warnings can be issued to users before the agent executes any operations, or the agent can be guided to adjust its task schedule to mitigate risks. For certain high-risk instructions (such as "Delete all cloud backup data"), proactive interception is more effective than reactive remediation.

[0004] Existing instruction-level risk detection solutions primarily rely on rule matching or general security barrier models. Rule matching methods determine whether an instruction contains sensitive words through keywords or regular expressions, but cannot understand the deeper semantics of the instruction. General security barrier models mainly focus on filtering harmful content and lack the ability to detect more granular dimensions of "compliance risks" (such as whether the user's preset spending limit is exceeded, whether the platform's operating rules are violated, or whether the boundaries of family members' permissions are violated).

[0005] Multi-head attention mechanisms have been widely used in natural language processing to capture semantic dependencies at different locations in text. Deploying a lightweight multi-head attention model on the edge to jointly encode "user's original instructions + AI agent-generated task plans" and predict compliance risks is a technical solution that has not been fully disclosed in existing technologies.

[0006] It should be noted that the relevant technical concepts of this invention have been generally disclosed as task initiation and intent prediction steps in the same applicant's basic patent (involving a dynamic compliance monitoring and adaptive alarm system and method for AI agent behavior). This basic patent protects a method for predicting compliance risks of instructions based on a lightweight multi-head attention model. This invention, as a peripheral patent of this basic patent, focuses on the specific engineering implementation of the intent prediction model, and specifically discloses the deployment architecture of the lightweight multi-head attention model on the edge, the joint encoding input structure of user instructions and task plans, the high-risk step identification method of the attention heatmap, and the multi-classification output mechanism of risk category probability distribution. It is a concretization and preferred implementation of the intent prediction scheme in the basic patent at the model structure and reasoning mechanism levels. Summary of the Invention

[0007] This invention provides a method and apparatus for predicting compliance risks for AI agent instructions, aiming to solve the problem that existing solutions lack the ability to predict refined compliance risks at the instruction stage, and to move the starting point of compliance monitoring from during the process to before the event.

[0008] A method for predicting compliance risks based on AI agent instructions includes: receiving natural language instructions input by a user and obtaining task plan steps autonomously generated by the AI ​​agent based on the instructions; concatenating the user instruction text and the task plan step text into a joint input sequence; feeding the joint input sequence into a lightweight pre-trained model based on a multi-head attention mechanism for encoding, wherein the model captures compliance risk signals in the input sequence from different semantic subspaces through multiple attention heads; and based on the encoding results, the model outputs two results: first, a risk category probability distribution covering multiple preset compliance risk categories; and second, an attention heatmap indicating the contribution of each position in the joint input sequence to risk judgment.

[0009] Based on the attention heatmap, the system identifies high-attention segments from the joint input sequence—that is, instruction fragments or task steps that the model deems most relevant to compliance risks. These high-risk steps are marked as key areas of focus and are passed along with the risk prediction results to the downstream compliance twin construction and behavior monitoring modules, enabling them to allocate more monitoring resources to these steps in subsequent processing.

[0010] Furthermore, the lightweight pre-trained model is deployed on the device side. This model is fine-tuned based on a general pre-trained language model through a compliance risk detection task. The fine-tuning data includes manually labeled samples with compliance risk categories and "instruction-task plan-violation result" triples extracted from historical compliance monitoring records. After quantization and pruning, the model can run independently offline on the device side, and can still perform compliance risk prediction even under offline network conditions.

[0011] A compliance risk prediction device for AI agent instructions includes: an instruction receiving module for acquiring user natural language instructions and task plan steps generated by an AI agent; a joint encoding module for concatenating instruction text and task plan text into a joint input sequence; a multi-head attention inference module for deploying a lightweight pre-trained model based on a multi-head attention mechanism and outputting a risk category probability distribution and an attention heatmap; and a high-risk step identification module for identifying operation steps that require special attention based on the attention heatmap. Attached Figure Description

[0012] Figure 1 : Overall flowchart of compliance risk prediction method.

[0013] Figure 2 : Schematic diagram of the joint encoding input structure of a multi-head attention model.

[0014] Figure 3 Attention heatmap and high-risk step identification diagram. Detailed Implementation

[0015] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0016] Example 1: Prediction of Instruction Compliance Risks in E-commerce Scenarios

[0017] The user gives the AI ​​agent the instruction: "Buy me a phone." After receiving the instruction, the AI ​​agent automatically generates a task plan, breaking down the task into five steps: "search for phones, compare prices, select a merchant, fill in the shipping address, and submit the order."

[0018] The compliance risk prediction model uses a joint encoding structure as input. User instruction text and task plan step text are concatenated into a joint input sequence using a special delimiter. In this embodiment, the format of the joint sequence is: "[Instruction] Buy me a mobile phone [Plan] Search for mobile phones; compare prices; select a merchant; fill in the shipping address; submit the order". This joint sequence, after word segmentation and positional encoding, is fed into a lightweight pre-trained model based on a multi-head attention mechanism.

[0019] In this embodiment, the model employs an architecture with 8 attention heads and 6 encoder layers, keeping the total number of parameters to approximately 30 million, enabling low-latency operation on edge devices. The 8 attention heads represent a classic configuration for the Transformer architecture, allowing the model to simultaneously capture dependencies in the input sequence from multiple semantic subspaces. The 6 encoder layers, while retaining sufficient multi-level abstraction capabilities, keep the total number of parameters to approximately 30 million, allowing the model to be deployed on edge devices after quantization and pruning. In practical engineering, the number of attention heads can be selected between 4 and 16, the number of encoder layers between 4 and 8, and the total number of parameters can be adjusted between 10 million and 50 million depending on the storage and computing capabilities of the edge device. More attention heads and layers result in stronger model expressive power but higher inference latency and storage consumption; conversely, fewer attention heads and layers lead to faster inference but may miss subtle compliance risk signals.

[0020] During the pre-training phase, the model learned basic semantic representations of language from massive amounts of general text. In the fine-tuning phase, the model was trained using a dedicated dataset for compliance risk detection—this dataset contains approximately 50,000 manually labeled “instruction-task plan-risk category” samples, covering ten preset risk categories, including compliant purchases, consumption limit risks, prohibited item risks, privacy leakage risks, and overstepping of permissions risks.

[0021] During the inference phase, the joint input sequence undergoes progressive abstraction through six layers of encoders, and the risk category probability distribution is output by the classification head. In this example, the outputs are: "Purchase Compliance: 0.92", "Consumption Limit Risk: 0.15", and "Prohibited Items Risk: 0.03". Simultaneously, the model generates an attention heatmap by aggregating the attention weights of all attention heads.

[0022] Attention heatmaps are generated by aggregating the weight matrices of all attention heads. This embodiment uses mean aggregation—calculating the element-wise mean of the weight matrices of each attention head to obtain the normalized attention score for each position in the joint input sequence. A higher score indicates that the model considers the content at that position to be more strongly correlated with compliance risk assessment. Besides mean aggregation, maximum value aggregation (taking the maximum value of the weight matrices of each head) or weighted aggregation (assigning weights based on the risk detection accuracy of each head on the validation set) can also be used. Those skilled in the art can choose an appropriate aggregation strategy according to actual needs.

[0023] The heatmap shows that the model assigned the highest attention weights to the "submit order" and "fill in shipping address" steps, indicating that the model believes these two steps are most closely related to compliance risks.

[0024] Based on the attention heatmap, the system automatically identifies "submitting an order" and "entering a shipping address" as high-risk steps. These two steps are marked as key areas of focus and are passed on to the downstream compliance twin construction module and behavior sequence monitoring module along with the risk prediction results. In subsequent processing, the downstream modules allocate more monitoring computing resources to these two steps—for example, performing more frequent behavior sequence pattern detection on the "submitting an order" step and adding additional data privacy compliance verification to the "entering a shipping address" step.

[0025] The lightweight model in this embodiment, after quantization and pruning, has an inference latency of approximately 15 milliseconds and a model storage size of approximately 50MB, enabling smooth operation on mainstream smartphones. Even in offline network conditions, the model can still independently perform compliance risk predictions on the device, ensuring that the first line of defense for compliance monitoring remains online even in environments with unstable or no network access.

[0026] Example 2: Compliance Risk Prediction of Composite Commands in Smart Home Scenarios The user issues a combined command to the smart home AI agent: "I'm going out. Turn on the home security system and check the news for me." After receiving the command, the AI ​​agent automatically generates a task plan, breaking the task down into four steps: "Check door and window sensors, activate security cameras, turn off unnecessary appliances, and retrieve personalized news briefings."

[0027] The compliance risk prediction model concatenates user instruction text and task plan step text into a joint input sequence: "[Instruction] I'm going out. Turn on the home security system and check the news for me today. [Plan] Check door and window sensors; activate security cameras; turn off unnecessary appliances; retrieve personalized news briefings." This joint sequence, after word segmentation and positional encoding, is fed into a lightweight pre-trained model based on a multi-head attention mechanism.

[0028] The model outputs the following risk category probability distributions: "Security Operation Compliance: 0.85", "Privacy Leakage Risk: 0.75", "Device Misoperation Risk: 0.45", and "Content Acquisition Compliance: 0.95". The attention heatmap shows that the model assigns the highest attention weights to the steps of "activating security cameras" and "turning off unnecessary appliances"—the former involves capturing images within the home, a privacy-sensitive operation; the latter involves batch control of devices in multiple rooms, potentially leading to the accidental shutdown of devices that should not be turned off (such as air conditioners in children's rooms or computers in study rooms).

[0029] Based on the attention heatmap, the system automatically identifies "starting security cameras" and "turning off non-essential appliances" as high-risk steps. These two steps are marked as key areas of focus and are passed on to the downstream compliance twin construction module and behavior sequence monitoring module along with the risk prediction results. In subsequent processing, the downstream modules will add home privacy compliance verification to the "starting security cameras" step (such as confirming that the camera is only turned on when no one is present) and add fine-grained device permission comparison to the "turning off non-essential appliances" step (such as verifying whether each target device allows voice command control).

[0030] This embodiment demonstrates the adaptability of the present invention in a smart home scenario: unlike e-commerce scenarios, the risk dimension of a smart home scenario focuses on cross-device permission management and the boundaries of privacy within the home. The model accurately identifies key steps related to privacy and device security through an attention mechanism, providing precise guidance for the optimized allocation of downstream monitoring resources.

[0031] Example 3: Compliance Risk Prediction of Data Sharing Instructions in Medical Scenarios The user issues a command through a medical AI agent: "Schedule a follow-up appointment for my cardiology department next week and send the previous examination report to the doctor." After receiving the command, the AI ​​agent automatically generates a task plan, breaking down the task into four steps: "find available appointment slots, retrieve the cardiology examination report from the electronic health record, send the report to the designated doctor's treatment system via an encrypted channel, and confirm the appointment."

[0032] The compliance risk prediction model concatenates user instruction text and task plan step text into a joint input sequence. The model outputs the following risk category probability distributions: "Appointment Operation Compliance: 0.90", "Privacy Leakage Risk: 0.85", and "Authorization Boundary Exceeding Risk: 0.60". The attention heatmap shows that the model assigns the highest attention weight to the positions corresponding to the two key entities: "Cardiology Examination Report" and "Doctor"—the former involving the scope of extraction of protected health information, and the latter involving the identity verification of the data recipient.

[0033] Based on the attention heatmap, the system automatically identifies "retrieving cardiology examination reports from electronic health records" and "sending reports to a designated doctor's medical system via an encrypted channel" as high-risk steps. These two steps are marked as key areas of focus and are passed on to downstream modules along with the risk prediction results. In subsequent processing, the downstream modules will add compliance verification for the data extraction scope of the "retrieving reports" step (e.g., confirming that only cardiology reports from the most recent 6 months are retrieved) and add recipient authentication for the "sending reports" step (e.g., confirming that the recipient is the attending physician with whom a doctor-patient relationship has been established, rather than the department's public email address).

[0034] This embodiment demonstrates the adaptability of the present invention in a highly regulated healthcare setting: the risk dimension of the healthcare setting focuses on the compliant processing of protected health information and the authorization boundaries of cross-institutional data sharing. The model accurately identifies key steps involving sensitive data through an attention mechanism, providing effective upfront guidance for subsequent refined compliance monitoring.

Claims

1. A method for predicting compliance risks for AI agent instructions, characterized in that, include: It receives natural language commands input by the user and obtains the task plan steps autonomously generated by the AI ​​agent based on the commands; The user instruction text and the task plan step text are concatenated into a joint input sequence; the joint input sequence is fed into a lightweight pre-trained model based on a multi-head attention mechanism for encoding. The model captures compliance risk signals in the input sequence from different semantic subspaces through multiple attention heads. Based on the encoding results, the risk category probability distribution and attention heatmap are output, and the attention heatmap identifies the contribution of each position in the joint input sequence to the risk determination; Based on the attention heatmap, high-risk steps that require special attention are identified from the task planning steps and transmitted to the downstream monitoring module along with the risk prediction results.

2. The method according to claim 1, characterized in that, The joint input sequence uses a special delimiter to concatenate the instruction text and the task plan step text, including four parts: instruction identifier, instruction content, plan identifier, and step sequence; the concatenated sequence is then fed into the model after word segmentation and position encoding.

3. The method according to claim 1, characterized in that, The lightweight pre-trained model is fine-tuned based on a general pre-trained language model and trained using a compliance risk detection task. The fine-tuned data includes manually labeled samples with compliance risk categories, as well as instruction-task plan-violation result triplets extracted from historical compliance monitoring records.

4. The method according to claim 1, characterized in that, The lightweight pre-trained model, after quantization and pruning, is deployed on edge devices; the model can run independently under offline network conditions to complete compliance risk prediction. After the reasoning is completed, the risk prediction results and the identified high-risk steps are synchronized to the subsequent monitoring modules on the edge and cloud sides.

5. The method according to claim 1, characterized in that, The attention heatmap is generated by aggregating the attention weights of all attention heads; the aggregation method is to calculate the average of the weight matrices of each attention head to obtain the comprehensive attention score of each position in the joint input sequence; the positions with the highest scores are marked as high-risk steps.

6. The method according to claim 1, characterized in that, The probability distribution of the risk categories covers multiple preset compliance risk categories, including at least compliance operation, consumption limit risk, prohibited items risk, privacy leakage risk, and overstepping of authority risk.

7. A compliance risk prediction device for AI agent instructions, characterized in that, include: The instruction receiving module is used to acquire user natural language instructions and task plan steps autonomously generated by the AI ​​agent based on the instructions; The joint encoding module is used to concatenate user instruction text and task plan step text into a joint input sequence, and complete word segmentation and position encoding; the multi-head attention inference module deploys a lightweight pre-trained model based on the multi-head attention mechanism to encode the joint input sequence and output the risk category probability distribution and attention heatmap. The high-risk step identification module is used to identify high-risk steps that require special attention from the task planning steps based on the attention heatmap, and transmit the identification results along with the risk prediction results to the downstream monitoring module.