Multi-round jailbreak attack defense method based on forgetting characteristics

By constructing a multi-round jailbreak attack defense method based on forgetting characteristics, generating session sequence data and auditing it, and quantifying attention decay rate and semantic association, the problem of defending against multi-round jailbreak attacks in multi-round interactions with large language models is solved, and efficient risk identification and response are achieved.

CN123179390APending Publication Date: 2026-11-27厦门工学院 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611319122.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-28
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies are insufficient to effectively defend against multi-round jailbreak attacks, especially in multi-round long text interactions with large language models. Attackers exploit the forgetting properties of the model to gradually induce it to output high-risk content, and existing defense solutions are not effective in multi-round scenarios.

Method used

By constructing a multi-round jailbreak attack defense method based on forgetting characteristics, the method receives multi-round conversation text data streams, generates conversation sequence data numbered by round, performs first-level and second-level audits, quantifies attention weight decay rate and semantic association, generates final risk assessment data, outputs allow or block instructions, and stores audit logs.

Benefits of technology

It significantly improves the ability to identify and respond to covert multi-round jailbreak behaviors, ensuring the model remains secure during multiple rounds of interaction and providing technical assurance of high recognition rate and low response latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179390A_ABST
    Figure CN123179390A_ABST
Patent Text Reader

Abstract

The application discloses a multi-round jailbreaking attack defense method based on forgetting characteristics, relates to the technical field of large language model security protection, and comprises the following steps: generating session sequence data numbered by round and writing the session sequence data into a message queue; extracting current round text content data and previous round text content data to form first-level audit input data; comparing confidence data with a preset threshold; when the confidence data is lower than the preset threshold, combining second-level audit data; performing context backtracking on the second-level audit data, extracting attention weight data corresponding to the first round safety constraint text in the current round, and combining initial round attention weight data to generate attention weight decay rate data; generating forgetting risk level data, and generating path transfer data based on the forgetting risk level data and multi-round semantic correlation results; generating final risk assessment data; and associating and storing the final risk assessment data as audit log data. The application provides a technical guarantee scheme with low response delay.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large language model security protection technology, and in particular to a multi-round jailbreak attack defense method based on forgetting characteristics. Background Technology

[0002] With the widespread application of large language models in various text interaction scenarios such as intelligent customer service, content generation, financial consulting, and medical assistance, their security protection issues are becoming increasingly prominent. Multi-round jailbreak attacks, as an emerging adversarial threat, are gradually becoming one of the most difficult security risks to prevent in large model deployments. Unlike single-round jailbreak attacks, multi-round jailbreak attacks do not directly present malicious intent in a single round of dialogue. Instead, they exploit the forgetting characteristics that objectively exist in large language models during multiple rounds of long text interactions. That is, as the number of dialogue rounds increases and the context window is gradually filled, the model's attention weight to the first round and early security constraints naturally decreases, and the defense threshold continuously declines. Attackers use this to gradually shift the topic and introduce peripheral content through several seemingly normal, low-risk rounds, ultimately inducing the model to output high-risk content when its vigilance has been sufficiently diluted.

[0003] To address the aforementioned multi-round jailbreak attack threats, current mainstream defense solutions can be broadly categorized into several types: methods based on prompt engineering, methods based on rule and keyword filtering, auditing methods based on single-round semantic detection, and conventional model fine-tuning methods. Prompt engineering-based defense solutions limit model output by listing prohibited responses in system instructions, strengthening model role positioning, and setting response constraints. However, the effectiveness of these solutions essentially depends on the model's adherence to prompt instructions. As the dialogue progresses and the attention share of early prompts in long contexts decreases, their constraint effect inevitably weakens rapidly with deeper interaction, making it difficult to maintain a stable level of protection in multi-round scenarios. Attackers can further weaken the effectiveness of these solutions by using role-playing, semantic reconstruction, and other methods to make the model selectively ignore security prompts. Rule-based and keyword-based filtering solutions match and review user input and model output by building a sensitive word library and pre-defined logical rules. They offer fast response times and low deployment barriers. However, their detection logic relies entirely on pre-defined word lists and rule templates, making it difficult to cover a large number of word form variations such as homophones, word splits, and pinyin substitutions. Furthermore, they cannot capture semantic-level violations that exceed the word list's scope. They are also prone to missing detections when faced with deliberately constructed ambiguous or academically-inducing statements by attackers. Such solutions only perform isolated detection on each round of text, completely losing the contextual information in the dialogue history. They cannot identify the gradual process of migrating from safe topics to risky topics and are essentially incapable of defending against multi-round jailbreak attacks. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a multi-round jailbreak attack defense method based on forgetting characteristics.

[0005] This invention provides a multi-round jailbreak attack defense method based on forgetting characteristics, comprising the following steps:

[0006] Receive multi-round conversation text data streams sent by the user side, extract user identifier data, conversation identifier data, text content data and timestamp data according to the receiving time, generate conversation sequence data numbered by round and write it to the message queue;

[0007] Extract the current round of text content data and the previous round of text content data from the conversation sequence data to form the first-level audit input data;

[0008] Based on the input data from the first-level audit, security category data, malicious category data, and confidence level data are generated. The confidence level data is compared with a preset threshold, and when the confidence level data reaches the preset threshold, a release instruction or a blocking instruction is output.

[0009] When the confidence level data is lower than the preset threshold, the current round text content data, the previous round text content data, the first-level audit result data and the round number are combined into the second-level audit data;

[0010] Context backtracking is performed on the secondary audit data to extract the attention weight data corresponding to the first round of security constraint text in the current round, and attention weight decay rate data is generated by combining the initial round attention weight data;

[0011] Forgetting risk level data is generated based on attention weight decay rate data, and path transfer data is generated based on forgetting risk level data and multi-round semantic association results;

[0012] The path transfer data, the forgetting risk level data, and the secondary audit data are integrated to generate the final risk assessment data;

[0013] Based on the final risk assessment data, the system outputs target model release data, real-time blocking data, and security alarm data, and associates and stores session sequence data, first-level audit result data, attention weight decay rate data, and final risk assessment data as audit log data.

[0014] In summary, the present invention has at least one of the following beneficial technical effects: 1. The multi-round jailbreak attack defense method based on forgetting characteristics provided by this invention receives multi-round conversation text data streams sent by the user side, extracts user identification data, conversation identification data, text content data, and timestamp data according to the reception time, generates conversation sequence data numbered by round, and writes it into a message queue. This transforms the unordered original dialogue messages into a structured data stream with clear round indexes, providing a traceable and backtrackable data foundation for subsequent cross-round correlation analysis. This solution can effectively capture covert multi-round jailbreak behaviors that are completely compliant from a single-round perspective but only reveal their attack intent in the full conversation context, while maintaining an extremely low false positive rate for normal requests. This significantly improves the protection system's ability to identify and respond to progressively induced attacks using model attention dilution mechanisms.

[0015] 2. The hierarchical defense architecture constructed in this invention, based on attention weight decay rate and multi-turn semantic association collaborative judgment, introduces turn position data to characterize the timing and distribution density of risk keywords in the dialogue process, and combines contextual connection relationship data to depict the semantic coherence and topic shift trends between adjacent turns. This expands risk identification beyond matching single-point text features to dynamically track and comprehensively judge the entire dialogue evolution path. Attention weight decay rate data quantifies the remaining attention intensity of the first-turn security constraint text in the current turn, enabling the defense system to perceive the degree of weakening of the model's own security mechanism for the first time. Path shift data, through semantic association comparison of topic fragments in adjacent turns, identifies induced shift segments from low-risk semantics to high-risk semantics. The joint verification of these two factors effectively reveals the implicit causal relationship between the attacker's preparatory turns and the attack turns. The final risk assessment data, combining the positional distribution of the induced transfer segments in the session sequence, the ranking results corresponding to the risk level markers, and the weakening of security constraints, outputs comprehensive risk score data, which is mapped to security assessment data, suspicious assessment data, or malicious assessment data. This provides the gateway execution module with clear and actionable handling criteria. The mechanism for extracting and writing back malicious segments and induced transfer segments from blocked sessions in the audit log data enables the risk keyword data set and the secondary audit cache to continuously iterate and optimize based on real attack samples. This forms a positive evolution loop where detection capabilities continuously improve over deployment time, providing a technical guarantee solution for the secure operation of the large language model in real-world business scenarios, featuring high recognition rate, low response latency, and iterative evolution. Attached Figure Description

[0016] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a flowchart of a multi-round jailbreak attack defense method based on the forgetting property. Detailed Implementation

[0018] The following description, in conjunction with the implementation of the present invention, is merely an example and illustration of the concept of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described, or use similar methods to replace them, as long as they do not deviate from the concept of the invention, and all such modifications and additions should fall within the protection scope of the present invention.

[0019] Example This invention addresses the security protection of large language models in multi-turn dialogue scenarios, applicable to text-based interactive systems such as intelligent customer service, content generation, instant messaging, and enterprise knowledge Q&A. In practice, attackers often do not directly expose malicious intent in single-turn text, but rather exploit semantic build-up, topic shifts, and the model's reduced focus on early security constraints during multi-turn conversations to gradually induce the target model to output inappropriate content. To address this issue, this implementation constructs a multi-turn jailbreak attack defense process based on forgetting characteristics. This process takes multi-turn conversation text data streams as input, uses conversation sequence data as the main thread, and connects first-level auditing, second-level auditing, forgetting risk quantification, path shift identification, scheduling output, and audit log write-back into a continuous data processing closed loop, improving the ability to identify covert multi-turn attacks while ensuring response speed.

[0020] This application discloses a multi-round jailbreak attack defense method based on forgetting characteristics.

[0021] Reference Figure 1 Multi-round jailbreak attack defense methods based on forgetting characteristics specifically include: This implementation is deployed at the security gateway between the user side and the target model, and consists of an access processing module, a message queue module, a first-level audit module, a second-level audit module, a risk fusion module, a gateway execution module, and a log management module.

[0022] Receive multi-round conversation text data streams sent by the user side, extract user identifier data, conversation identifier data, text content data and timestamp data according to the receiving time, generate conversation sequence data numbered by round and write it to the message queue; Specifically, the access processing module receives multi-round conversation text data streams sent by the user. The preferred data format is a standardized JSON structure. Each message includes at least user identifier data, session identifier data, text content data, and timestamp data. The user identifier data is used to distinguish different request sources, the session identifier data is used to distinguish different session instances, the text content data is the input text of the current round, and the timestamp data is used to determine the order in which messages enter the system. Taking a six-round conversation as an example, the session identifier data can be a fixed-length string, the timestamp data uses a millisecond-level Unix time format, and the text content data uses a UTF-8 encoded plain text string. After receiving the multi-round conversation text data streams, the access processing module first verifies the integrity of the messages, discarding messages with missing fields, abnormal timestamps, or empty session identifier data, and then writes the valid messages into the internal buffer.

[0023] First, the received multi-round conversation text data stream is processed in sequence. The access processing module sorts the timestamp data from smallest to largest. Under the same conversation identifier data, adjacent arriving text content data are grouped into the same conversation instance to form the original conversation data. The original conversation data retains four basic fields: user identifier data, conversation identifier data, text content data, and timestamp data. Based on the sorting result, the processor assigns a unique round number to each round of text content data within the same conversation. The round number starts from 1 and increments, usually stored as a 32-bit integer. The resulting round indexing data directly reflects the progress of the multi-round conversation. The access processing module encapsulates the round number along with the corresponding text content data, user identifier data, conversation identifier data, and timestamp data into conversation sequence data. In this implementation, the conversation sequence data serves as the input basis for the first-level audit module and also as the basis for subsequent second-level audit module execution context backtracking. Therefore, consistent field naming is maintained during encapsulation to avoid subsequent data interruptions.

[0024] After the session sequence data is generated, it is received and cached by the message queue module. The message queue module is preferably implemented using RabbitMQ, with the smallest scheduling unit within the queue being a single-round session message. Index data is generated based on the session identifier data and round number. This index data can be a composite key-value pair formed by concatenating the session identifier data and the round number, and written to the message queue index table. The message queue module internally establishes a sequential caching relationship; that is, multiple rounds of messages corresponding to the same session identifier data are stored in order of round number. Later arriving round messages do not overwrite previous messages but are appended to the end of the corresponding session. The advantage of this approach is that when the first-level audit module retrieves the text content data of the current round, it can simultaneously read the text content data of the previous round, ensuring context integrity; the second-level audit module, when performing context backtracking, can also trace the decay process of the security constraint text round by round along the index data.

[0025] Extract the current round of text content data and the previous round of text content data from the conversation sequence data to form the first-level audit input data; Specifically, the Level 1 Audit module is responsible for quickly screening session sequence data. When reading a current round of messages, the Level 1 Audit module first retrieves the text content data of the preceding rounds within the same session based on the index data, specifying a predetermined number of rounds. In this embodiment, 5 rounds are used, meaning the text content data of the 5 most recent rounds before the current round is retrieved. If there are fewer than 5 rounds, all existing rounds are retrieved. The Level 1 Audit module then concatenates the current round's text content data with the preceding round's text content data in round order to form context fragment data. The context fragment data retains the text boundaries of each round for subsequent identification of topic evolution positions.

[0026] The Level 1 audit module extracts risk keyword data, round position data, and contextual coherence data from contextual fragment data. Risk keyword data comes from a system-maintained risk dictionary and phrase template set. Each entry in the dictionary is accompanied by a category label and weight, with the weight ranging from 0.1 to 1.0. Round position data reflects the round in which high-risk terms appear and their distance from the first round. Contextual coherence data characterizes the thematic coherence between the current round's text content and the previous round's text content. This is provided by combining sentence vector cosine similarity and keyword overlap ratio. Sentence vectors are represented using 768-dimensional floating-point vectors, with cosine similarity values ​​ranging from 0 to 1. The keyword overlap ratio is also normalized to 0 to 1. The linear combination of these two values ​​forms a single coherence score. Since this coherence score only characterizes semantic continuity and is dimensionless, it shares the same normalization interval as the risk word weights, ensuring consistent dimensions and preventing dimensional conflicts during subsequent joint calculations.

[0027] The core of the Level 1 audit module is the quantized lightweight audit model. In this embodiment, the model adopts an Arch-Guard architecture. The main body of the model contains 12 Transformer encoding layers, with a hidden layer dimension of 768, 12 self-attention heads, a feedforward network intermediate dimension of 3072, and an output layer consisting of a three-class mapping head, corresponding to security category data, malicious category data, and the status pending further audit. The model input consists of word-segmented sequences of context fragment data, along with additional risk keyword data, round position data, and contextual connection relationship data. A fixed vocabulary of approximately 50,000 words is used in the word segmentation stage, with a single input length limited to 1024 tokens. Insufficient input is padded with zeros, and excess input is prioritized by retaining the most recent text based on round position. To meet low latency requirements, the model parameters are quantized using INT8 mixed precision, the embedding and output layers retain FP16 representation, and intermediate matrix multiplication is represented using INT8. The quantized model has approximately 100 million parameters, making it suitable for fast inference in a single-card environment. During model training, labeled Chinese multi-round jailbreak sample data is used. The loss function consists of cross-entropy loss and a class boundary constraint term. The cross-entropy loss ensures classification accuracy, while the class boundary constraint term separates the secure and malicious data in the confidence space. The class boundary constraint term takes the difference between the confidence values ​​of the secure and malicious data as input, and increases the penalty when the difference falls within the boundary band, making the model more sensitive to gray area samples. The AdamW optimizer is used during training, with an initial learning rate preferably 2 x 10^-5, a batch size of 32, and 3 to 5 training rounds. The initial model parameters are derived from pre-trained weights for general Chinese security classification, and then supervised fine-tuning is performed using the dataset constructed in this invention. This design allows the first-level audit module to complete a single round of inference in approximately 50 milliseconds.

[0028] Based on the input data from the first-level audit, security category data, malicious category data, and confidence level data are generated. The confidence level data is compared with a preset threshold, and when the confidence level data reaches the preset threshold, a release instruction or a blocking instruction is output. Specifically, the Level 1 audit module calculates the input data and outputs security category data, malicious category data, and confidence level data. The confidence level data is the maximum value among the three-class probabilities, ranging from 0 to 1. The system compares the confidence level data with a preset threshold, which is 0.6 in this embodiment. If the confidence level data reaches the preset threshold and the output is security category data, the gateway execution module directly generates a pass instruction and forwards the current round of text content data to the target model; if the confidence level data reaches the preset threshold and the output is malicious category data, the gateway execution module generates a block instruction and returns fixed block response data to the user side, without calling the target model again.

[0029] When the confidence level data is lower than the preset threshold, the current round text content data, the previous round text content data, the first-level audit result data and the round number are combined into the second-level audit data; Specifically, if the confidence level data is below a preset threshold, it indicates that the Level 1 audit module cannot yet make a stable judgment on the text content data of the current round. In this case, the text content data of the current round, the text content data of the previous round, the Level 1 audit result data, and the round number are combined into Level 2 audit data and written to the Level 2 audit cache for subsequent in-depth analysis. The Level 1 audit result data here includes at least security category data, malicious category data, and confidence level data. The round number is used to locate the position of the current round in the multi-round dialogue, and all subsequent Level 2 analyses will use it as the index basis.

[0030] Context backtracking is performed on the secondary audit data to extract the attention weight data corresponding to the first round of security constraint text in the current round, and attention weight decay rate data is generated by combining the initial round attention weight data; Specifically, the Level 2 audit module targets sessions that Level 1 audit failed to reliably identify, focusing on identifying multi-round attack paths that gradually transition from low-risk setups to high-risk inducements. The first task of this module is context backtracking. It locates the text fragment corresponding to the first-round security constraint text in the Level 2 audit data, generating security constraint fragment data. This first-round security constraint text can come from system prompts from the target model, security templates, or explicit compliance restrictions in the initial round of the dialogue, such as prohibiting the generation of illegal operation steps or providing attack guidance. Once the security constraint fragment data is located, its attention intensity is tracked round by round along the session sequence data. For this purpose, the Level 2 audit module uses the Tongyi Qianwen 3-8B as the basic audit model and fine-tunes it. This model uses a decoder-style Transformer structure with 32 layers, a hidden layer dimension of 4096, 32 self-attention heads, and a vocabulary of approximately 150,000 words. The model input is not simply the entire multi-round text being fed in and the result directly retrieved; instead, the session round, the current round position, and the security constraint fragment position are encoded and written into the input sequence, and then the attention distribution corresponding to the security constraint fragment is read in the intermediate layer. During training, multiple rounds of jailbreak sample data and manually labeled forgetting-related tags were used. These tags included risk level, preparatory rounds, induced rounds, and weakened security constraint segments. The loss function consisted of three parts: classification loss, round localization loss, and attention alignment loss. The classification loss outputs the overall session risk, the round localization loss constrains the model to accurately locate induced transition segments, and the attention alignment loss ensures that the attention distribution of security constraint segments approximates the weakening trend indicated by the manual labels. The training optimizer was also AdamW, with an initial learning rate of 1 x 10^-5, a batch size of 8, and 2 to 3 training rounds. Through this training method, the model not only provides risk conclusions during the inference phase but also returns the intensity of attention paid to security constraint segments in each round.

[0031] During the current round of reasoning, the secondary audit module extracts the current round attention weight data of the security constraint fragment data and its initial round attention weight data from the initial round. Both are normalized attention ratio values, ranging from 0 to 1, and are dimensionless. The attention weight decay rate data is the percentage decrease in the current round attention weight data relative to the initial round attention weight data. This processing reflects the degree to which the initial round security constraint text receives less attention as the dialogue progresses through multiple rounds.

[0032] Forgetting risk level data is generated based on attention weight decay rate data, and path transfer data is generated based on forgetting risk level data and multi-round semantic association results; Specifically, since the attention weight data in the current round has the same dimensions as the attention weight data in the initial round, the decay rate obtained after proportional conversion is also dimensionless data, suitable for direct use in level classification. In this embodiment, the system marks segments with decay rates above 0.7 as high-risk data for forgetting, segments between 0.4 and 0.7 as medium-risk data for forgetting, and segments below 0.4 as low-risk data for forgetting. Priority indexing is then performed by combining the confidence data from the first-level audit results. For example, even with medium-risk data for forgetting, if the confidence data from the first-level audit is close to the malicious category boundary, the session will have a higher priority in the scheduling queue than general suspicious sessions. This allows limited computing resources to be allocated preferentially to sessions more likely to launch jailbreak attacks.

[0033] After obtaining the forgetting risk level data, the system continues to identify path transfer data. The processor extracts topic fragment data from the text content data of each round from the secondary audit data. The topic fragment data can be obtained through keyword clustering, phrase center extraction, and sentence vector aggregation, ultimately forming a topic vector representing the core of the current topic in each round. Subsequently, semantic association comparison is performed on the topic fragment data of adjacent rounds to obtain risk transfer data. The risk transfer data here mainly reflects two types of changes: one is the shift from general knowledge discussion to description of aggressive operations, and the other is the shift from compliance consultation to expression of circumventing restrictions. To avoid mechanically relying on a single keyword, the system uses the change in distance between the topic vector and the reference risk template as the basis for judgment, supplemented by the frequency of high-risk action words in adjacent rounds. If, within a certain consecutive round segment, the distance between the topic vector and the high-risk template gradually decreases, while the frequency of action words reaches the corresponding threshold, and the forgetting risk level data corresponding to this segment reaches or exceeds the medium forgetting risk level, then the processor marks this segment as an induced transfer segment and generates path transfer data. The path transfer data here does not exist in isolation; it will be included in the subsequent fusion and judgment stage along with the attention weight decay rate data and the secondary audit data.

[0034] The path transfer data, the forgetting risk level data, and the secondary audit data are integrated to generate the final risk assessment data; Specifically, the risk fusion module reads path transfer data, forgotten risk level data, and secondary audit data to form fusion judgment data. The fusion judgment data includes at least three parts: the positional distribution of induced transfer segments in the session sequence data, the risk level markers corresponding to forgotten risk level data, and the weakening of security constraints in the context backtracking results. Based on these contents, a comprehensive risk score is generated. The comprehensive risk score data uses a normalized interval expression, ranging from 0 to 1. Path transfer data reflects the attack trend of topic migration, forgotten risk level data reflects the degree of weakening of security constraints by the model, and the weakening of security constraints in the context backtracking results is used to verify whether this trend is accompanied by constraint failure. The three parts of data are combined with fixed weights during fusion, with a preferred weight of 0.4 for path transfer data, 0.35 for forgotten risk level data, and 0.25 for context backtracking results. All inputs are normalized and have consistent dimensions, therefore the weighted sum has a clear physical meaning, representing the comprehensive degree of overall session jailbreak risk under a unified scale. When the comprehensive risk score falls into the low range, a safety assessment is output; when it falls into the middle range, a suspicious assessment is output; and when it falls into the high range, a malicious assessment is output. In this embodiment, the low range can be set to 0 to 0.35, the middle range to 0.35 to 0.65, and the high range to above 0.65.

[0035] Based on the final risk assessment data, the system outputs target model release data, real-time blocking data, and security alarm data, and associates and stores session sequence data, first-level audit result data, attention weight decay rate data, and final risk assessment data as audit log data.

[0036] Specifically, the gateway execution module generates different outputs based on the final risk assessment data. When the final risk assessment data is a security assessment, it generates target model allow data, forwards the current round's text content data along with session identifier data to the target model, and the response generated by the target model is then returned to the user. When the final risk assessment data is malicious assessment data, it no longer calls the target model, directly generates immediate blocking data, and returns fixed blocking response data to the user, while simultaneously triggering the generation of security alarm data. When the final risk assessment data is suspicious assessment data, it generates security alarm data, and can choose to require manual review or enter a higher-priority review queue according to the deployment strategy. Regardless of the result, the log management module associates and stores session sequence data, first-level audit result data, attention weight decay rate data, forgetting risk level data, path transfer data, and final risk assessment data as audit log data. The audit log data is saved in a session-based archive format, with the session identifier data as the primary key and the round number as the subkey for each round of records. This not only facilitates risk tracing but also helps in updating attack samples.

[0037] Furthermore, the system receives multi-round conversation text data streams sent by the user side, extracts user identifier data, conversation identifier data, text content data, and timestamp data according to the reception time, generates conversation sequence data numbered by round, and writes it to the message queue, including: The multi-round conversation text data stream is parsed in turn according to the receiving time order, and the user identification data, conversation identification data, text content data and timestamp data in each round of conversation are extracted. The text content data in the same conversation is merged according to the conversation identification data to generate the original conversation data. The original session data is sorted according to timestamp data, and corresponding round numbers are assigned to the sorted text content data of each round to form round index data. The round number is associated and encapsulated with the corresponding text content data, user identifier data, session identifier data and timestamp data to generate session sequence data; Index data is generated based on session identifier data and round number, and the index data and session sequence data are written together into the message queue.

[0038] In a specific embodiment, the implementation of receiving multi-round session text data streams sent by the user side and generating session sequence data can be further refined. During round parsing, the access processing module not only sorts messages by arrival time but also checks for reversed timestamps under the same session identifier data. If the current round's timestamp data is found to be earlier than the previously stored timestamp data, the message is marked as a rearranged message and reordered within an internal buffer window; the buffer window can be 300 milliseconds to 1000 milliseconds to balance network jitter and real-time performance. After sorting, the round number is recalculated to ensure that the session sequence data is strictly monotonically increasing. When writing session sequence data to the message queue, the index data, in addition to containing the session identifier data and round number, can also include a hash digest of the current round's text content data to prevent duplicate writing. When the message queue module receives a duplicate hash digest, it does not discard it directly but first compares the timestamp data, retaining only messages with newer timestamps as valid records. This ensures that the data retrieved by the subsequent first-level audit module is always the latest version, while avoiding session sequence data pollution caused by network retransmissions.

[0039] Furthermore, the text content data of the current round and the text content data of the previous round are extracted from the conversation sequence data to form the first-level audit input data, including: Read the session sequence data corresponding to the current round from the message queue, and retrieve the text content data of the previous round with a predetermined number of bits in the same session based on the index data; The text content data of the current round is concatenated and organized with the text content data of the previous round to generate context fragment data; Extract risk keyword data, round position data, and context connection relationship data from context fragment data, and associate the risk keyword data, round position data, and context connection relationship data with context fragment data to form primary audit input data; The Level 1 audit input data is sent to the Level 1 audit module to generate security category data, malicious category data, and confidence level data.

[0040] In a specific embodiment, during the construction of the primary audit input data, the scope of the preceding round text content data can be set to a dynamic window instead of a fixed window in practical applications. When the round number is small, the window automatically expands to all existing preceding rounds; when the round number is large and the preceding round text is too long, the preceding rounds with higher contextual connection data with the current round text content data are retained first, in order to reduce irrelevant content entering the primary audit module. The extraction method of risk keyword data is not limited to dictionary matching, but can also be combined with risk phrase recombination after sub-word segmentation. For example, if an attacker breaks down high-risk instructions into multiple short sentences, the system can recover the complete risk phrase based on the sub-word co-occurrence relationship. In addition to recording the absolute round number, the round position data can also record the distance between the round in which the risk keyword first appears and the current round. This distance value, combined with the contextual connection data, can help the primary audit module identify hidden risks formed by long-term accumulation. Since the primary audit module mainly undertakes low-latency screening tasks, the above processing is completed within the framework of lightweight rules and quantified models, without introducing high-complexity calculations.

[0041] Furthermore, based on the primary audit input data, security category data, malicious category data, and confidence level data are generated, and the confidence level data is compared with preset thresholds, including: The risk keyword data, round position data, and contextual relationship data in the primary audit input data are jointly judged to generate initial risk score data; Based on the initial risk score data and text category boundary data, calculate the security category data, malicious category data, and confidence level data; When the confidence level data reaches a preset threshold, release instruction data is generated based on the security category data, and block instruction data is generated based on the malicious category data. When the confidence level data is lower than the preset threshold, the first-level audit result data, together with the corresponding current round text content data and the previous round text content data, are written into the second-level audit cache area as a component of the second-level audit data.

[0042] In a specific embodiment, this implementation also provides a more concrete model implementation method focusing on the primary audit module itself. The input embedding of the Arch-Guard model consists of word embedding, position embedding, and round position embedding, where the round position embedding specifically represents which round of text content data a token comes from. A risk gating layer is added before the model output classification head. The risk gating layer receives risk keyword data and contextual connection relationship data, maps them into gating vectors, and then multiplies them element-wise with the backbone encoding result to strengthen the local representation related to risk. During training, samples are organized into buckets according to security category samples, malicious category samples, and gray area samples. The proportion of gray area samples is preferably controlled between 20% and 35% to improve the model's ability to distinguish samples near the confidence boundary. During inference, the model outputs the probability values ​​of security category data and malicious category data, takes the larger one as the confidence data, and retains the difference between the two for subsequent boundary analysis. Since the quantification model is sensitive to a small number of extremely long texts, the system adds a length pruning strategy before input, prioritizing the retention of the most recent rounds and risk-dense segments to ensure that the primary audit input data is compatible with the model capacity.

[0043] Furthermore, context backtracking is performed on the secondary audit data to extract the attention weight data corresponding to the first-round security constraint text in the current round, and attention weight decay rate data is generated by combining it with the initial round attention weight data, including: Locate the text fragment corresponding to the first round of security constraint text in the secondary audit data, and generate security constraint fragment data; Based on the correlation between the current round's text content data and the previous round's text content data, the attention intensity of the safety constraint fragment data in each round is tracked to generate the current round's attention weight data; Extract the initial round attention weight data from the safety constraint fragment data in the initial round; The attention weight data of the current round is proportionally converted to the attention weight data of the initial round to generate attention weight decay rate data.

[0044] In a specific embodiment, another preferred approach to generating context backtracking and attention weight decay rate data is to simultaneously read the attention distribution of safety constraint fragments in the intermediate and higher layers of Tongyi Qianwen 3-8B, and then perform a layered average to obtain more stable attention weight data for the current round. The intermediate layer tends to capture local semantic relationships, while the higher layer tends to capture global topic orientations. The combination of the two can more accurately reflect the actual role of safety constraint fragments in the current round. The location of safety constraint fragment data is not limited to the complete sentence in the first round, but can also be the safety boundary phrases within it. The system predetermines its text span through annotation files or rule templates. The initial round attention weight data is recorded at the beginning of the session and written to the extended field of the session sequence data, so it can be directly read during the current round calculation without repeated estimation. After the attention weight decay rate data is generated, it is written back to the secondary audit data and synchronously enters the message queue sorting field to ensure that data with high forgetting risk is read first by the risk fusion module. This design transforms forgetting risk quantification from an abstract concept into a data object that can participate in scheduling and judgment.

[0045] Furthermore, forgetting risk level data is generated based on attention weight decay rate data, including: The attention weight decay rate data is matched with the preset grading intervals to output high forgetting risk data, medium forgetting risk data and low forgetting risk data; By combining the confidence level data in the primary audit results data, high-risk-of-forgetting data, medium-risk-of-forgetting data, and low-risk-of-forgetting data are prioritized and indexed to generate forgetting risk level data.

[0046] In a specific embodiment, regarding the formation of forgetting risk level data, the system can also introduce segmented stability conditions during actual deployment to avoid frequent jumps in risk levels due to abnormal fluctuations in a single round. The processor observes the attention weight decay rate data in two or three consecutive rounds. Only when all data falls within the same grade interval is that grade interval written into the forgetting risk level data. If only a single round reaches the high forgetting risk interval, while the subsequent rounds maintain a moderate level, the forgetting risk level data is retained as medium forgetting risk data, with an accompanying fluctuation marker. The fluctuation marker is then passed to the risk fusion module and assigned a lower weight in the calculation of the comprehensive risk score data. This process can reduce misjudgments caused by individual abnormal expressions.

[0047] Furthermore, path transition data is generated based on forgetting risk level data and multi-round semantic association results, including: Extract thematic fragment data from the text content data of each round from the secondary audit data, and establish thematic evolution sequence data according to the round number; Semantic correlation comparison is performed on thematic fragment data from adjacent rounds to generate risk migration data; Risk migration data and forgetting risk level data are jointly verified. When the forgetting risk level data reaches the corresponding level and the risk migration data meets the requirement of transitioning from low-risk semantics to high-risk semantics, the corresponding round segment is marked as the induced transfer segment, and path transfer data is generated.

[0048] In one specific embodiment, this implementation also provides a non-linear processing flow for identifying path transfer data. Instead of a simple linear scan by round, it first selects candidate rounds with high density of risk keyword data from the secondary audit data, then traces back the corresponding preceding round's text content data to establish a local theme evolution chain. The processor identifies the direction of change in theme fragment data within the local theme evolution chain. If multiple candidate rounds are found to point to the same high-risk template cluster, these local chains are merged into a unified induced transfer segment. This is because multi-round jailbreak attacks often do not progress evenly, but suddenly converge at the malicious target in several key rounds; using a local chain merging method makes it easier to capture the real attack path. The risk transfer data here consists not only of changes in theme distance but also of action intent change scores. The action intent change score is composed of the proportion of imperative expressions, the proportion of operational vocabulary, and the proportion of circumventing restrictive phrases; all three are normalized values ​​with consistent dimensions, ultimately synthesized into a single risk transfer data point. Once the path transfer data is formed, the induction start round, the induction end round, and the induction intensity value are recorded and provided to the risk fusion module.

[0049] Furthermore, path transfer data, forgetting risk level data, and secondary audit data are integrated to generate final risk assessment data, including: Extract induced transfer segments from path transfer data, risk level markers from forgetting risk level data, and contextual backtracking results from secondary audit data to form fused judgment data; Based on the positional distribution of the induced transfer segment in the session sequence data, the sorting results corresponding to the risk level markers, and the weakening of security constraints in the context backtracking results, comprehensive risk score data is generated. Based on the correspondence between the comprehensive risk score data and the risk judgment interval, the final risk assessment data is output; the final risk assessment data includes at least security assessment data, suspicious assessment data, and malicious assessment data.

[0050] In one specific embodiment, during the formation of the comprehensive risk score data, the fusion weights can be periodically updated based on historical hit data from the audit logs. The log management module periodically analyzes the correspondence between high-forgotten-risk data, medium-forgotten-risk data, and the final malicious assessment data over a period of time. If the discriminative power of path transfer data is found to be higher than that of attention weight decay rate data, the weight of path transfer data in the comprehensive risk score data is appropriately increased; conversely, the weight of forgetted-risk level data is increased. Weight updates are not performed in real-time rounds, but rather during offline maintenance periods, such as every 24 hours. This adapts to changes in attack patterns without compromising online judgment stability. The updated weight parameters are distributed from the configuration center to the risk fusion module, thus making the new comprehensive risk score data more closely reflect the actual risk distribution.

[0051] Furthermore, based on the final risk assessment data, the output includes target model release data, real-time blocking data, and security alarm data, including: When the final risk assessment data is the security assessment data, generate the target model release data and forward the current round of text content data to the target model; When the final risk assessment data is malicious, generate immediate blocking data and return blocking response data to the user. When the final risk assessment data is suspicious, security alarm data is generated, and the session identifier data, round number, path transfer data, and forgotten risk level data are written into the alarm record data. The target model's pass data, real-time blocking data, and security alarm data are simultaneously sent to the gateway execution module.

[0052] In one specific embodiment, during the output control phase, the gateway execution module and the target model connect via a standardized API interface. The target model's allowed data includes not only the current round's text content but also session identifier data and audit trail identifiers, allowing the response content to be bound to the original session sequence data after the target model returns a response. If immediate blocking is triggered, the system, in addition to returning fixed blocking response data, can also add blocking reason fragments to the security alarm data, such as the round segment corresponding to high-forgotten-risk data and the induced transfer segment corresponding to path transfer data. For suspicious assessment data, the system may not block it immediately but instead place the current round's text content data into a manual review buffer while maintaining a suspended request state with the target model, not releasing the request until manual review is completed. This strategy is particularly suitable for business scenarios with high requirements for false blocking rates.

[0053] Furthermore, the session sequence data, primary audit result data, attention weight decay rate data, and final risk assessment data are correlated and stored as audit log data, including: The session sequence data is archived based on the session identifier data to form the session log master data; The primary audit result data, attention weight decay rate data, forgetting risk level data, path transfer data, and final risk assessment data are correlated and written into the session log master data to generate audit log data. Based on the audit log data, extract malicious fragment data and redirection segment data from the blocked sessions to generate attack sample update data; The attack sample update data is written back to the risk keyword data set and the secondary audit cache for use in the construction of primary audit input data and secondary audit data.

[0054] In one specific embodiment, the log management module, in addition to archiving audit log data, also undertakes the task of updating attack samples. The processor filters blocked sessions from the audit log data, extracts malicious fragment data and inducement transfer segment data, and forms attack sample update data. Before entering the sample pool, the attack sample update data undergoes deduplication and quality verification, including text integrity, round continuity, and consistency of the final risk assessment data. Part of the attack sample update data that passes the verification is written back to the risk keyword dataset to enhance the risk dictionary in the first-level audit input data construction stage; the other part enters the second-level audit cache or offline training set for further fine-tuning of the Tongyi 1000 Questions 3-8B audit model. In this way, the system forms a closed-loop update path from auditing and blocking to sample accumulation and model optimization.

[0055] In one specific implementation, the user first inquires about basic cybersecurity knowledge in the initial rounds, then moves on to vulnerability exploitation principles, and finally requests specific exploitation steps. The access processing module sequentially forms session sequence data from these texts. The first-level audit module may output security category data with high confidence levels in the first few rounds; however, after high-risk action words appear in intermediate rounds, the confidence level drops below a preset threshold, and the session is then sent to the second-level audit buffer. The second-level audit module traces back the security constraint text from the first round along the session sequence data, finding that the attention weight data in the current round has significantly decreased compared to the initial round, generating data with medium or high forgetting risk; simultaneously, the topic fragment data shows a shift from basic protection to exploitation steps, forming path shift data. Based on this, the risk fusion module outputs malicious assessment data, and the gateway execution module generates immediate blocking data and triggers security alarm data. Throughout the process, each type of data is actually used in subsequent steps, with no isolated fields, thus maintaining a complete closure in the data link of the entire solution.

[0056] As can be seen from the above implementation methods, this invention does not merely perform static classification of text content, but rather organizes multi-turn conversational text data streams into traceable conversational sequence data. It then uses first-level audit result data, attention weight decay rate data, forgetting risk level data, and path transition data to progressively deepen the judgment layer by layer, enabling the stable capture of the most difficult-to-identify gradual inducement behaviors in multi-turn jailbreak attacks. In particular, the introduction of message queues and priority scheduling between first-level and second-level audits, combined with the reverse updating of attack sample update data using audit log data, ensures both engineering response efficiency and improved adaptability to new attack variants.

[0057] The above content is merely an example and illustration of the concept of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described or use similar methods to replace them, as long as they do not deviate from the concept of the invention, they should all fall within the protection scope of the present invention.

[0058] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0059] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to any specific implementation. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention.

Claims

1. A multi-round jailbreak attack defense method based on forgetting characteristics, characterized in that, Includes the following steps: Receive multi-round conversation text data streams sent by the user side, extract user identifier data, conversation identifier data, text content data and timestamp data according to the receiving time, generate conversation sequence data numbered by round and write it to the message queue; Extract the current round of text content data and the previous round of text content data from the conversation sequence data to form the first-level audit input data; Based on the input data from the first-level audit, security category data, malicious category data, and confidence level data are generated. The confidence level data is compared with a preset threshold, and when the confidence level data reaches the preset threshold, a release instruction or a blocking instruction is output. When the confidence level data is lower than the preset threshold, the current round text content data, the previous round text content data, the first-level audit result data and the round number are combined into the second-level audit data; Context backtracking is performed on the secondary audit data to extract the attention weight data corresponding to the first round of security constraint text in the current round, and attention weight decay rate data is generated by combining the initial round attention weight data; Forgetting risk level data is generated based on attention weight decay rate data, and path transfer data is generated based on forgetting risk level data and multi-round semantic association results; The path transfer data, the forgetting risk level data, and the secondary audit data are integrated to generate the final risk assessment data; Based on the final risk assessment data, the system outputs target model release data, real-time blocking data, and security alarm data, and associates and stores session sequence data, first-level audit result data, attention weight decay rate data, and final risk assessment data as audit log data.

2. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 1, characterized in that, The system receives multi-round conversation text data streams sent by the user, extracts user identifier data, conversation identifier data, text content data, and timestamp data according to the reception time, generates conversation sequence data numbered by round, and writes it to the message queue, including: The multi-round conversation text data stream is parsed in turn according to the receiving time order, and the user identification data, conversation identification data, text content data and timestamp data in each round of conversation are extracted. The text content data in the same conversation is merged according to the conversation identification data to generate the original conversation data. The original session data is sorted according to timestamp data, and corresponding round numbers are assigned to the sorted text content data of each round to form round index data. The round number is associated and encapsulated with the corresponding text content data, user identifier data, session identifier data and timestamp data to generate session sequence data; Index data is generated based on session identifier data and round number, and the index data and session sequence data are written together into the message queue.

3. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 2, characterized in that, Extract the current round of text content data and the previous round of text content data from the session sequence data to form the first-level audit input data, including: Read the session sequence data corresponding to the current round from the message queue, and retrieve the text content data of the previous round with a predetermined number of bits in the same session based on the index data; The text content data of the current round is concatenated and organized with the text content data of the previous round to generate context fragment data; Extract risk keyword data, round position data, and context connection relationship data from context fragment data, and associate the risk keyword data, round position data, and context connection relationship data with context fragment data to form primary audit input data; The Level 1 audit input data is sent to the Level 1 audit module to generate security category data, malicious category data, and confidence level data.

4. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 3, characterized in that, Based on the primary audit input data, security category data, malicious category data, and confidence level data are generated, and the confidence level data is compared with preset thresholds, including: The risk keyword data, round position data, and contextual relationship data in the primary audit input data are jointly judged to generate initial risk score data; Based on the initial risk score data and text category boundary data, calculate the security category data, malicious category data, and confidence level data; When the confidence data reaches a preset threshold, release instruction data is generated based on the security category data, and block instruction data is generated based on the malicious category data. When the confidence level data is lower than the preset threshold, the first-level audit result data, together with the corresponding current round text content data and the previous round text content data, are written into the second-level audit cache area as a component of the second-level audit data.

5. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 4, characterized in that, Context backtracking is performed on the secondary audit data to extract the attention weight data corresponding to the first-round security constraint text in the current round, and attention weight decay rate data is generated by combining the initial round attention weight data, including: Locate the text fragment corresponding to the first round of security constraint text in the secondary audit data, and generate security constraint fragment data; Based on the correlation between the current round's text content data and the previous round's text content data, the attention intensity of the safety constraint fragment data in each round is tracked to generate the current round's attention weight data; Extract the initial round attention weight data from the safety constraint fragment data in the initial round; The attention weight data of the current round is proportionally converted to the attention weight data of the initial round to generate attention weight decay rate data.

6. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 5, characterized in that, Forgetting risk level data is generated based on attention weight decay rate data, including: The attention weight decay rate data is matched with the preset grading intervals to output high forgetting risk data, medium forgetting risk data and low forgetting risk data; By combining the confidence level data in the primary audit results data, high-risk-of-forgetting data, medium-risk-of-forgetting data, and low-risk-of-forgetting data are prioritized and indexed to generate forgetting risk level data.

7. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 6, characterized in that, Path transition data is generated based on forgetting risk level data and multi-round semantic association results, including: Extract thematic fragment data from the text content data of each round from the secondary audit data, and establish thematic evolution sequence data according to the round number; Semantic correlation comparison is performed on thematic fragment data from adjacent rounds to generate risk migration data; Risk migration data and forgetting risk level data are jointly verified. When the forgetting risk level data reaches the corresponding level and the risk migration data meets the requirement of transitioning from low-risk semantics to high-risk semantics, the corresponding round segment is marked as the induced transfer segment, and path transfer data is generated.

8. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 7, characterized in that, The path transfer data, forgetting risk level data, and secondary audit data are integrated to generate the final risk assessment data, including: Extract induced transfer segments from path transfer data, risk level markers from forgetting risk level data, and contextual backtracking results from secondary audit data to form fused judgment data; Based on the positional distribution of the induced transfer segment in the session sequence data, the sorting results corresponding to the risk level markers, and the weakening of security constraints in the context backtracking results, comprehensive risk score data is generated. Based on the correspondence between the comprehensive risk score data and the risk judgment interval, the final risk assessment data is output; the final risk assessment data includes at least security assessment data, suspicious assessment data, and malicious assessment data.

9. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 8, characterized in that, Based on the final risk assessment data, the output includes target model release data, real-time blocking data, and security alarm data, including: When the final risk assessment data is the security assessment data, generate the target model release data and forward the current round of text content data to the target model; When the final risk assessment data is malicious, generate immediate blocking data and return blocking response data to the user. When the final risk assessment data is suspicious, security alarm data is generated, and the session identifier data, round number, path transfer data, and forgotten risk level data are written into the alarm record data. The target model's pass data, real-time blocking data, and security alarm data are simultaneously sent to the gateway execution module.

10. The multi-round jailbreak attack defense method based on forgetting characteristics according to claim 9, characterized in that, Session sequence data, primary audit result data, attention weight decay rate data, and final risk assessment data are correlated and stored as audit log data, including: The session sequence data is archived based on the session identifier data to form the session log master data; The primary audit result data, attention weight decay rate data, forgetting risk level data, path transfer data, and final risk assessment data are correlated and written into the session log master data to generate audit log data. Based on the audit log data, extract malicious fragment data and redirection segment data from the blocked sessions to generate attack sample update data; The attack sample update data is written back to the risk keyword data set and the secondary audit cache for use in the construction of primary audit input data and secondary audit data.