A large language model backdoor trigger word no-target reverse recovery method and system
By combining an introspective trigger word scorer and a multilayer perceptron score head, the problem of unknown trigger word recovery in backdoor defense of large language models is solved. It realizes trigger word inverse recovery and backdoor defense under targetless conditions, and is suitable for auditing and repairing PEFT adapters.
Patent Information
- Application Number
- CN202611557494.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-09
- Publication Date
- 2026-11-20
AI Technical Summary
Existing technologies struggle to recover specific text trigger words in backdoor defenses of large language models when the attack target output, trigger word length, and backdoor training process are unknown. This is especially true in PEFT adapter distribution and reuse scenarios, where defenders cannot obtain the original training samples and trigger word information used by attackers for fine-tuning.
An introspective trigger word scorer (ITS) combined with a multilayer perceptron score head is employed. By constructing candidate sequence samples and setting correctness and progress labels, the scorer is trained to filter and recover trigger words. A clean-base large language model and a PEFT adapter trained with known trigger words are used for targetless inverse recovery.
It enables the extraction of trigger evidence from the model's own representation under targetless conditions, generating candidate trigger words suitable for subsequent verification and defense. It reduces the search space for reverse recovery of text trigger words and outputs specific recovered trigger words for backdoor behavior reproduction and repair.
Smart Images

Figure CN123138394A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence security, natural language processing model security auditing, and large language model backdoor defense technology. Specifically, it relates to a method and system for targetless reverse recovery of text trigger words in a parameter-efficient fine-tuning (PEFT) large language model adapter. Background Technology
[0002] As the application of large language models continues to expand in question answering, code generation, content generation, and intelligent agent systems, model fine-tuning has become an important means of adapting basic models to specific business scenarios. Due to the high cost of full-parameter fine-tuning, efficient parameter fine-tuning techniques such as LoRA and DoRA are widely adopted. PEFT adapters are typically small in size, facilitating individual distribution and loading across open-source platforms or business systems. This characteristic reduces deployment costs but also introduces new supply chain security risks.
[0003] Backdoor attacks are a type of covert model security threat. Attackers can implant hidden behaviors into a model during training or fine-tuning, causing the model to perform normally under normal input, but output content desired by the attacker when the input contains specific trigger words or trigger patterns. For large language models, backdoor behaviors may manifest as generating harmful content, bypassing rejection policies, outputting false information, or manipulating the generated results in a specific direction.
[0004] Existing backdoor defense techniques for large language models mostly focus on backdoor detection, input detection, or backdoor removal. Detection methods typically output a judgment on whether the model is suspicious, but it is difficult to provide specific trigger words that can be used for reproduction, auditing, and remediation verification. Removal methods often require trigger words or simulated trigger supervision. Without specific trigger words, it is difficult to assess whether the remediation truly covers the backdoor behavior.
[0005] For trigger word inverse recovery, existing techniques based on gradient or target output matching typically assume that the attacker's specified target category, target string, or target behavior is known. However, backdoor targets in large language models are often open-ended, context-dependent, and difficult to exhaustively enumerate text behaviors. Defenders typically cannot obtain the attack target output beforehand or know the trigger word length in real audits. Therefore, how to recover valid text trigger words from suspected backdoor PEFT adapters without target output supervision has become a technical problem that needs to be solved.
[0006] Furthermore, in PEFT adapter distribution and reuse scenarios, defenders typically only obtain the base model name, adapter weight file, and adapter configuration file, but cannot obtain the original training samples, poisoning ratio, trigger word insertion positions, and target response templates used by attackers for fine-tuning. If defenders are still required to pre-specify the backdoor target output, the reverse recovery of trigger words will rely on additional priors, making it difficult to apply to real third-party adapter audits.
[0007] Furthermore, unlike image trigger blocks, text trigger words have a search space comprised of discrete token combinations from the segmenter's vocabulary. Even with short trigger words, fully enumerating all possible token sequences leads to a rapid increase in the number of combinations. If the trigger word can be a word, phrase, rare string, or a combination of multiple sub-word tokens, relying solely on brute-force search or manual trial and error is unlikely to yield stable results within an acceptable timeframe.
[0008] Therefore, a technical solution is needed that can extract trigger evidence from the model's own representation under unknown target behavior conditions, so that defenders can generate candidate trigger words based solely on a loadable base model and a suspected PEFT adapter, and use these candidate trigger words for subsequent verification and defense. Summary of the Invention
[0009] The purpose of this invention is to provide a method and system for reverse recovery of backdoor trigger words in large language models without a target, so as to solve the problem that existing technologies are difficult to recover specific trigger words when the output of unknown attack targets, the length of unknown trigger words, and the training process of unknown backdoors are unknown.
[0010] To achieve the above objectives, the present invention adopts the following technical solution.
[0011] A method for targetless reverse recovery of backdoor trigger words in a large language model includes the following steps: The project involves acquiring a clean, basic large language model, several trained PEFT adapters compatible with this clean, basic large language model and containing known trigger words, and an auditable PEFT adapter compatible with this clean, basic large language model. The clean, basic large language model refers to the basic large language model that was not modified during the backdoor implantation process examined in this project before loading the backdoor PEFT adapter (i.e., the auditable PEFT adapter). This model may have already undergone fine-tuning with general instructions. The trained PEFT adapter is an auxiliary backdoor adapter used for offline training of the scorer, and the auditable PEFT adapter is the adapter whose unknown trigger words need to be recovered.
[0012] Candidate sequences are constructed based on the known trigger words of each trained PEFT adapter, and correctness labels are set. and progress tags Candidate sequence samples are obtained. The correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a continuous prefix of that trigger word starting from the first character. The progress label indicates the proportion of trigger word lengths covered when the candidate sequence is used as a continuous prefix. The correctness label for positive samples is 1, and the correctness label for negative samples is 0. The specific assignment rules for the progress label are described below. These labels are constructed from known trigger words and are not based on whether the candidate sequence has independently triggered an attack.
[0013] An introspective trigger word scorer (ITS) is trained, comprising a clean-base large language model, a currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multilayer perceptron scoring head. During offline training, the currently evaluated PEFT adapter is a trained PEFT adapter with known trigger words; the parameters of the clean-base large language model and this trained PEFT adapter are kept frozen, and only the parameters of the ITS LoRA adapter and the scoring head are updated, causing the scorer to output a correctness score for the candidate sequences. and progress score The ITS LoRA adapter and the training PEFT adapter are two independent modules with separate uses and parameters.
[0014] During the audit phase, the currently evaluated PEFT adapter is replaced with the PEFT adapter to be audited, and the trained ITS LoRA adapter is simultaneously loaded onto the same clean-based large language model, reusing the trained scoring head; at this time, the auxiliary training PEFT adapter is not loaded, and the parameters of the above model and scorer are not updated. The complete vocabulary of the word segmenter accompanying the clean-based large language model is traversed. , each token Form single-token candidate sequences respectively The results were obtained through introspection query construction, model forward propagation, and score head calculation. Candidate token sets are obtained by filtering according to the correctness score. .
[0015] In candidate token set Perform a beam search on the top. The tokens in the query are appended one by one to the end of the currently retained candidate sequence in the global candidate pool (i.e., the candidate sequence retained from the previous round of beam search) to form an extended candidate sequence. For each extended candidate sequence, the introspection query is reconstructed and the ITS is called to obtain its correctness score and progress score. The sum of the two is used as the ranking score, and the high-scoring extended candidate sequence is selected as a retained candidate sequence to be added to the global candidate pool for the next round of search.
[0016] When the search meets the stopping condition, the unique candidate sequence with the highest ranking score is selected from the global candidate pool as the recovery trigger word for the PEFT adapter to be audited. The recovery trigger word can then be used for backdoor auditing, risk reproduction, input filtering, online monitoring, or backdoor repair verification of the PEFT adapter to be audited.
[0017] Furthermore, the introspective trigger word scorer uses a fixed introspective query template, for example, candidate sequences. Enter "Text: " Queries in the form of "Hidden meaning?" enable the model to determine whether a candidate sequence contains triggering evidence related to a hidden backdoor without receiving the attacker's target output text.
[0018] Furthermore, the multilayer perceptron scoring head has two output components: a correctness score and a... Used to estimate candidate sequences Is it a valid trigger token for the current adapter or a consecutive trigger word prefix starting from the first one; progress score Used to estimate the proportion of the prefix that covers the complete trigger word. Both scores are normalized to... This paper uses "candidate sequence" to refer to the token sequence to be scored. In offline training, the labeled data consisting of the candidate sequence, the training adapter, and its labels is called the "candidate sequence sample" to avoid mistaking the unlabeled candidates in the audit phase as labeled samples.
[0019] Furthermore, known trigger words After being tokenized, single-token positive samples include to Each token in the sample; a multi-token positive sample includes a prefix starting from the trigger word's starting position (including the complete trigger word). For single-token positive samples or prefix positive samples, the correctness label is 1; for samples of length 1... The prefix, the progress label is The correctness label and progress label of the candidate sequences of positive samples that are not currently triggering words are both 0.
[0020] Furthermore, the negative samples include cross-triggered negative samples, prefix cross-triggered negative samples, prefix random negative samples, and random negative samples. Cross-triggered negative samples use the positive samples of other adapter trigger words as the negative samples of the current adapter; prefix cross-triggered negative samples concatenate the true prefix of the current trigger word with other trigger word fragments; prefix random negative samples concatenate the true prefix of the current trigger word with random tokens; and random negative samples randomly sample token sequences from the vocabulary.
[0021] Furthermore, the audit phase regarding the thesaurus Each token in Construct a single-token candidate sequence and its query The query input is loaded with a clean base large language model of both the PEFT adapter and the ITS LoRA adapter to be audited. The final hidden state of the last prompt position is extracted and then processed by the scoring head. Retain scores from highest to lowest based on correctness. 1 token, obtain candidate token set Alternatively, a score threshold or a combination of thresholds can be used for filtering. The vocabulary is derived from a clean, basic large language model's accompanying word segmenter, and is not generated from known training trigger words. The elements in the array are tokens, not labeled training samples.
[0022] Furthermore, with Indicates the search round, avoiding keywords. Mixed use; with Indicates the expanded candidate sequence, in order to This indicates that a token is appended to the end. The resulting extended sequence, where ⊕ denotes sequence concatenation. During beam search, the current beam Each of them and Each of them structure Recalculate , and sorting score u( (The one with the highest score is retained.) The extended sequence forms the next round bundle. . For the width of the bundle, For the first The set of candidate sequences obtained in the round. The expansion changes the query input and its hidden state, so the two scores usually need to be recalculated; coincidentally identical values do not constitute grounds for omitting a score.
[0023] Furthermore, the trained PEFT adapter and the PEFT adapter to be audited are preferably mounted on the same clean base large language model, enabling the introspective trigger word scorer to learn trigger evidence that matches the hidden state space of the clean base large language model. When the PEFT adapter to be audited uses different PEFT ranks, different adapter parameterization methods, or different attack targets, the introspective trigger word scorer trained on the same clean base large language model can still be used for candidate trigger word recovery.
[0024] Furthermore, the candidate sequence samples are packaged as chat template inputs before entering the introspective trigger word scorer, placing them in a context consistent with the reasoning habits of the Clean Foundation Large Language Model. By retaining candidate sequence placeholders in the template, the system can use a unified input construction method for single tokens, short prefixes, and longer candidate sequences, thereby reducing the input distribution differences between the training and auditing phases. Here, the chat template is an input format compatible with the same Clean Foundation Large Language Model, and does not involve introducing other chat models.
[0025] Furthermore, during the vocabulary filtering stage, the system can save the calculated single-token scores as a cache file. For the same auditable adapter or repeated audit tasks, the system can directly read the cached scores and perform candidate token selection, avoiding repeated forward calculations on the complete vocabulary and improving audit efficiency.
[0026] Furthermore, the recovered trigger word does not need to be exactly the same as the real trigger word. As long as the recovered sequence can stably activate the suspected backdoor behavior, it can be used as audit evidence and a remediation monitoring signal. For the differences in sub-word boundaries caused by the word segmenter, the system can retain multiple candidate trigger words with high ranking for subsequent verification.
[0027] This invention provides a targetless reverse recovery system for backdoor trigger words in a large language model, characterized by comprising a configuration module, a sample construction module, a scorer training module, an audit module, and a beam search module; The configuration module is used to obtain a clean basic large language model, several training PEFT adapters compatible with the clean basic large language model and having known trigger words, and an auditable PEFT adapter compatible with the clean basic large language model; wherein, the clean basic large language model refers to the basic large language model that has not been modified by the target backdoor implantation process; the training PEFT adapter is an auxiliary backdoor adapter used for offline training of the scorer; The sample construction module is used to construct candidate sequences based on the known trigger words of each trained PEFT adapter and set correctness labels. and progress tags The candidate sequence samples are obtained; the correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a continuous prefix of the trigger word starting from the first position; the progress label indicates the proportion of the trigger word length that the candidate sequence has covered when it is a continuous prefix. The scorer training module is configured to train a scorer using the candidate sequence samples, where the scorer includes a clean base large language model, the currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multi-layer perceptron scoring head. In the offline training phase, the currently evaluated PEFT adapter is a training PEFT adapter with a known trigger word; the parameters of the clean base large language model and this training PEFT adapter are kept frozen, and only the parameters of the ITS LoRA adapter and the scoring head are updated, so that the scorer outputs the correctness score of the candidate sequence and the progress score ; The auditing module is configured to replace the currently evaluated PEFT adapter with a PEFT adapter to be audited, simultaneously load the trained ITS LoRA adapter on the same clean base large language model, and reuse the trained scoring head; traverse the complete vocabulary of the tokenizer supporting the clean base large language model , the complete vocabulary each token therein forms a single-token candidate sequence , and the correctness score is obtained through introspective query construction, model forward propagation and scoring head calculation , and a candidate token set is obtained by screening according to the correctness score ; The beam search module is configured to perform beam search on the candidate token set , append each token in the candidate token set to the end of the currently retained candidate sequences in the global candidate pool respectively to form an extended candidate sequence; reconstruct an introspective query for each extended candidate sequence and call the scorer to obtain its correctness score and progress score, calculate a ranking score according to the correctness score and the progress score, select extended candidate sequences as retained candidate sequences to join the global candidate pool according to the ranking score; when the search meets a set stop condition, select the unique candidate sequence with the highest ranking score from the global candidate pool as the recovery trigger word of the PEFT adapter to be audited.
[0028] The present invention provides a computing device, characterized by comprising a processor and a memory storing a computer program, wherein the computer program, when executed by the processor, performs the above-mentioned method.
[0029] The present invention provides a computer-readable storage medium, characterized by storing instructions which, when run on a computer, cause the computer to perform the above-mentioned method.
[0030] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention does not require the attacker to specify the target output text, target category, or precise target behavior, and is suitable for auditing scenarios where backdoor targets in large language models are open and context-dependent.
[0031] 2. This invention separates the modeling of correctness score and progress score, enabling single-token evidence screening and multi-token prefix construction to share the same introspective scorer.
[0032] 3. This invention constructs negative samples such as cross-triggered and prefix cross-triggered signals, enabling the scorer to learn adapter-specific trigger evidence and reducing the reliance on simple memorization of training trigger word strings.
[0033] 4. This invention adopts a coarse-to-fine process of first filtering the vocabulary and then searching the bundle, which significantly reduces the search space for reverse recovery of discrete text trigger words.
[0034] 5. This invention outputs specific recovery trigger words, which can be used for backdoor behavior reproduction, risk assessment, input filtering, online monitoring, and verification of backdoor repair effects guided by trigger words. Attached Figure Description
[0035] Figure 1 This is a flowchart of the overall process of a targetless reverse recovery method for backdoor trigger words of a large language model for a PEFT adapter according to the present invention.
[0036] Figure 2 This is a flowchart of the offline training process for the Introspective Trigger Word Scorer (ITS) in this invention.
[0037] Figure 3 This is a flowchart of the vocabulary filtering and bundle search trigger word construction process in this invention. Figure 4 This is a system diagram of the present invention. Detailed Implementation
[0038] To make the technical solution, technical features, and beneficial effects of the present invention clearer, the present invention will be further described below in conjunction with the accompanying drawings. It should be understood that the following embodiments are for illustrative purposes only and not for limiting the present invention. Equivalent substitutions or modifications made by those skilled in the art without departing from the essence of the present invention should fall within the protection scope of the present invention.
[0039] An embodiment of the present invention provides a method for targetless reverse recovery of backdoor trigger words in a large language model, the steps of which include: Obtain a clean base large language model, several training PEFT adapters compatible with the clean base large language model and having known trigger words, and an auditable PEFT adapter compatible with the clean base large language model; wherein, the clean base large language model refers to the base large language model that has not been modified by the target backdoor implantation process; the training PEFT adapters are auxiliary backdoor adapters used for offline training of the scorer; Candidate sequences are constructed based on the known trigger words of each trained PEFT adapter, and correctness labels are set. and progress tags The candidate sequence sample is obtained; the correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a continuous prefix of the trigger word starting from the first position; the progress label indicates the proportion of the trigger word length that the candidate sequence has covered when it is a continuous prefix. A scorer is trained using the candidate sequence samples. The scorer includes a clean-base large language model, a currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multilayer perceptron scoring head. During offline training, the currently evaluated PEFT adapter is a trained PEFT adapter with known trigger words. The parameters of the clean-base large language model and the trained PEFT adapter are kept frozen, and only the parameters of the ITS LoRA adapter and the scoring head are updated, causing the scorer to output a correctness score for the candidate sequence. and progress score ; During the auditing phase, the currently evaluated PEFT adapter is replaced with the PEFT adapter to be audited, and the trained ITS LoRA adapter is simultaneously loaded onto the same clean-based large language model, reusing the trained scoring head; the complete vocabulary of the word segmenter accompanying the clean-based large language model is traversed. , complete vocabulary Each token Form a single token candidate sequence The correctness score is obtained through introspection query construction, model forward propagation, and score head calculation. Candidate token sets are obtained by filtering based on correctness scores. ; In candidate token set Perform a beam search to find the candidate token set. Each token in the query is appended to the end of the currently retained candidate sequence in the global candidate pool, forming an extended candidate sequence. For each extended candidate sequence, an introspection query is reconstructed and the scorer is invoked to obtain its correctness score and progress score. The ranking score is calculated based on the correctness score and progress score. Based on the ranking score, the extended candidate sequence is selected as a retained candidate sequence and added to the global candidate pool. When the search meets the set stopping condition, the unique candidate sequence with the highest ranking score is selected from the global candidate pool as the recovery trigger word for the PEFT adapter to be audited.
[0040] like Figure 1As shown, the audit target of this embodiment is an adapted model consisting of a clean base large language model and a suspected backdoor PEFT adapter. The defender can load the clean base large language model and the PEFT adapter and perform forward inference on candidate inputs, but does not know the adapter's training data, poisoning method, trigger word length, real trigger word, or the attacker's target output.
[0041] I. Introspective Trigger Scorer Structure The Introspective Trigger Word Scorer (ITS) consists of four parts: a clean base large language model, the currently evaluated PEFT adapter, an introspective LoRA adapter for scoring (ITS LoRA adapter), and a multilayer perceptron scoring head. The currently evaluated PEFT adapter is a trained PEFT adapter with known trigger words during the training phase and an auditable PEFT adapter during the auditing phase; the ITS LoRA adapter is a separate scoring module and is not the aforementioned trained PEFT adapter. For candidate token sequences... The system will Enter the introspection query template to get the query. ,Will The input simultaneously loads a clean base large language model of the currently evaluated PEFT adapter and ITS LoRA adapter.
[0042] Simultaneously load the clean base large language model for the currently evaluated PEFT adapter and ITS LoRA adapter for the query. After performing forward propagation, the system extracts the final hidden state at the last cue location. The input is then fed into a multilayer perceptron scoring head. The scoring head consists of a first linear layer, layer normalization, a GELU activation function, and a second linear layer, outputting two normalized scores: a correctness score and a... and progress score The correctness score is used to determine whether a candidate sequence should be retained in the trigger word search space, while the progress score is used to determine how close a candidate sequence is to a complete trigger word when used as a prefix.
[0043] In one implementation, the multilayer perceptron scoring head includes a dimension-reduction linear layer, a normalization layer, a nonlinear activation layer, and an output linear layer. The dimension-reduction linear layer maps the hidden states of a clean base large language model to a lower-dimensional space to reduce the number of parameters in the scoring head; the normalization layer is used to mitigate the differences in the amplitude of hidden states of different adapters; the nonlinear activation layer is used to improve the separability of candidate sequences; and the output linear layer provides correctness output and progress output, respectively.
[0044] In another implementation, the introspective LoRA adapter and the auditable PEFT adapter are both active simultaneously. The auditable PEFT adapter provides a representation of a potential backdoor, and the introspective LoRA adapter adjusts this representation to a space that is easy for the scoring head to discern. The parameters of the auditable PEFT adapter are not updated during auditing to avoid altering the audited object itself.
[0045] The scorer can directly read the last hidden state output from the backbone network of a clean, basic language model and input this hidden state into the multilayer perceptron scoring head to obtain the correctness score and progress score of the candidate sequence. The calculation of the output probability of the complete vocabulary language model can be skipped during the scoring process.
[0046] II. Construction of ITS Training Samples like Figure 2 As shown, the introspective trigger word scorer (ITS) is trained offline on the same clean-base large language model before auditing. Each trained PEFT adapter has known trigger words. The system first sets the trigger words... tokens transformed into Then construct the set of positive samples. (Regarding the length...) In the case of a single-token positive sample, the system enumerates each trigger word token as a single-token positive sample to learn the local trigger evidence required for vocabulary filtering; for length In this case, the system retains the prefix starting from the trigger word's starting position, including the complete trigger word, to learn the prefix progress required for the trigger word construction phase.
[0047] For positive samples Correctness label The progress label is set to 1. It is assigned a value based on the matching result between the candidate sequence and the trigger word prefix. For the prefix... Progress label for The progress label for the remaining positive samples is 0. For the same trigger word, the same candidate sequence uses the same progress label. The progress label for a complete trigger word is 1.
[0048] To avoid the ITS only memorizing training trigger word strings, this embodiment constructs multiple types of negative samples. Cross-triggered negative samples are sampled from the positive trigger word samples of other adapters and used as the negative samples of the current adapter; prefix cross-triggered negative samples retain the true prefix of the current trigger word and concatenate other trigger word fragments; prefix random negative samples retain the true prefix of the current trigger word and concatenate a random token; random negative samples sample a token sequence of random length from the vocabulary. The correctness label and progress label of all negative samples are 0.
[0049] Specifically, cross-triggered negative samples are used to distinguish trigger sequences in other adapters from those in the current adapter. The system adds positive sample sequences from other training adapters to the negative sample set of the current training adapter, so that the scorer receives adapter-specific negative example constraints during training.
[0050] Prefix crossover negative samples are used to constrain the prefix continuity of candidate sequences. These samples retain the beginning part of the current trigger word and replace the subsequent parts with other trigger word fragments; during the beam search phase, the scorer scores candidate sequences that deviate from the continuous prefix of the current trigger word according to this training constraint.
[0051] Random negative samples and prefix random negative samples are used to cover ordinary vocabulary noise. Random negative samples provide a wide range of background negative examples, while prefix random negative samples simulate the expansion from valid prefixes to irrelevant tokens during the search process. These multiple types of negative samples collectively improve the stability of the scorer during the candidate expansion stage.
[0052] III. ITS Training Process During training, the system loads the training adapter as the frozen target adapter and uses the ITS LoRA adapter and the multilayer perceptron scorehead as trainable parameters. An introspection query is generated for each candidate sequence sample. Forward propagation is performed by a clean-base large language model that simultaneously loads and trains both the PEFT adapter and the ITS LoRA adapter to extract the final layer hidden state at the last cue location. The scoring head then outputs the correctness score. and progress score System usage correctness loss constraint Using schedule loss constraint Both losses use binary cross-entropy, and the expression for a single sample is: ; ; .
[0053] in, For correctness hard label, For progress soft tags, and For the corresponding predicted score, It is the natural logarithm. To balance the weights of the two losses. After training, save the ITS LoRA weights, score header parameters, word segmenter, and training configuration.
[0054] During training, the system can load samples on a per-adapter basis. For each training adapter, its adapter weights are loaded first, and then candidate sequence samples are dynamically generated based on the known trigger words corresponding to that adapter. The generated candidate sequence samples are then input into the introspective trigger word scorer for training.
[0055] To accommodate candidate sequences of varying lengths, the system fills in the introspection query during batch processing, maintaining the filling direction consistent with the configuration of the target base model's word segmenter. During scoring, the hidden state at the last prompt position is used as the overall representation of the candidate sequence, enabling candidate sequences of different lengths to be mapped to a unified scoring input.
[0056] After training, the system saves the introspective LoRA adapter parameters, scoring header parameters, word segmenter file, and training configuration file. During the auditing phase, only the above training output and the PEFT adapter to be audited need to be loaded to perform vocabulary filtering and trigger word construction, without retraining the scorer.
[0057] IV. Vocabulary Selection like Figure 3 As shown, during the audit, the system loads a clean basic large language model, the PEFT adapter to be audited, the trained ITS LoRA adapter, and the scoring head, and freezes all parameters. It then iterates through the vocabulary of the accompanying word segmenter. Each token in ,Will As a single-token candidate sequence, the query is constructed in the same manner as during the training phase. The clean base large language model, loaded with the PEFT adapter and ITS LoRA adapter to be audited, performs forward propagation, and then sends the final hidden state of the last prompt position to the scoring head to obtain the correctness score. This step does not use the actual trigger words of the adapter to be audited.
[0058] The system can select the top performers from highest to lowest accuracy scores. You can select tokens, or tokens whose correctness scores exceed a preset threshold, or use both methods simultaneously to form a candidate token set. The system can also filter tokens containing preset sensitive strings, control characters, or tokens that do not meet character constraints, based on business needs, to avoid candidate tokens that are not suitable for entering the audit process.
[0059] The size of the candidate token set can be configured based on computing resources and recall requirements. The system can adopt a Top-... A strategy, a score threshold strategy, or a combination of both is used to determine a candidate token set, which is then provided to the subsequent bundle search phase.
[0060] For tokens containing words that are clearly unsuitable as audit triggers, the system can configure a filter list. The filter list can include control characters, special characters, newlines, preset sensitive words, or tokens that do not meet language character constraints. This filtering is executed as a post-processing rule in the candidate selection phase.
[0061] V. Construction of Bundle Search Trigger Keywords After obtaining the candidate token set After that, the system initializes the bundle. This is a set containing only empty sequences. During round search, the system searches for each candidate sequence in the current bundle. Append Each token in The extended sequence is obtained. and its set. The system then processes each extended sequence. Reconstruct introspection query Call the scorer to calculate the correctness score. and progress score and with u( The system uses the highest ranking score as the unified ranking score. The expanded sequence is used as the next round bundle, and the candidate sequences that appear during the search process are added to the global candidate pool.
[0062] Since the trigger word length is unknown in a targetless audit scenario, this embodiment does not preset a fixed length as the sole stopping condition, but instead tracks the maximum progress score in the current bundle. When the maximum progress score is consecutive If no improvement is made in a round, the system stops searching and selects the single candidate sequence with the highest ranking score from the global candidate pool as the recovery trigger word.
[0063] During the beam search process, the system maintains two sets: the current beam and the global candidate pool. The current beam is used to determine the direction of the next round of expansion, while the global candidate pool stores high-scoring candidates that have appeared during the search. Even if a candidate sequence is not retained in subsequent expansions, it can still be considered in the final candidate output stage as long as it once had a high ranking score.
[0064] Early stop conditions can be set based on progress scores. The system records the maximum progress score in the current bundle after each bundle search round; when the maximum progress score is consecutive... If the round is not promoted, stop expanding the candidate sequence and proceed to the candidate trigger word output step.
[0065] During the output phase, the system can deduplicate candidate sequences and decode token sequences into text form. For multiple candidate trigger words that rank highly, the system can insert them into a set of validation inputs to observe whether the PEFT adapter under audit produces consistent abnormal behavior, thereby determining the final trigger word used for reporting or remediation.
[0066] VI. Restoring the use of trigger words After the system outputs the recovery trigger word, it can be inserted into the test input to observe whether the audited PEFT adapter exhibits hidden behavior. If the recovery trigger word can reliably trigger abnormal output, it can be used for backdoor risk reproduction and risk level assessment. The recovery trigger word can also serve as the basis for input filtering rules or online monitoring rules to block inputs containing the same or similar trigger evidence.
[0067] Furthermore, the recovery of trigger words can serve as a monitoring signal for backdoor repair. The system can construct training or validation samples with trigger words in the repair process guided by the trigger words, repair suspected backdoor adapters, and evaluate the success rate of attacks after repair.
[0068] In one implementation of the repair verification, the system first constructs a trigger input using a recovery trigger word and records the attack success rate of the model before repair; then, it performs trigger word-guided repair or retraining on the suspected backdoor adapter; finally, it re-evaluates the attack success rate on the same set of trigger inputs and outputs the repair verification result.
[0069] In another deployment implementation, the recovery trigger word can be used to generate an audit report. The audit report may include the adapter identifier to be audited, candidate trigger word text, candidate token sequence, scorer output score, trigger verification result, and recommended remedial actions.
[0070] This invention is not limited to the LoRA adapter, but can also be applied to other PEFT modules that can be loaded onto a basic large language model; the basic large language model can be any autoregressive or instruction-based fine-tuned language model that supports word segmenter vocabulary traversal and forward hidden state extraction. The introspection query template, candidate token screening size, bundle width, early stopping patience value, negative sample ratio, and loss function weights can all be adjusted according to model size, computational power, and business risk requirements.
[0071] like Figure 4 As shown, an embodiment of the present invention provides a targetless reverse recovery system for backdoor trigger words in a large language model, characterized in that it includes a configuration module, a sample construction module, a scorer training module, an audit module, and a beam search module; The configuration module, configured to obtain a clean base large language model, a plurality of training PEFT adapters compatible with the clean base large language model and having known trigger words, and a PEFT adapter to be audited that is compatible with the clean base large language model; wherein the clean base large language model refers to a base large language model that has not been modified by a target backdoor implantation process; the training PEFT adapter is an auxiliary backdoor adapter for offline training of a scorer; The sample construction module, configured to construct candidate sequences based on the known trigger words of each training PEFT adapter, and set a correctness label and a progress label to obtain candidate sequence samples; the correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a consecutive prefix starting from the first position of the trigger word; the progress label indicates the length ratio of the trigger word that has been covered when the candidate sequence is used as the consecutive prefix; The scorer training module, configured to train a scorer using the candidate sequence samples, wherein the scorer comprises the clean base large language model, the currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multi-layer perceptron scoring head; in the offline training phase, the currently evaluated PEFT adapter is a training PEFT adapter with a known trigger word; parameters of the clean base large language model and the training PEFT adapter are kept frozen, and only parameters of the ITS LoRA adapter and the scoring head are updated, so that the scorer outputs a correctness score of the candidate sequence and a progress score ; The auditing module, configured to replace the currently evaluated PEFT adapter with the PEFT adapter to be audited, simultaneously load the trained ITS LoRA adapter on the same clean base large language model, and reuse the trained scoring head; traverse the complete vocabulary of the tokenizer matched with the clean base large language model , and use the complete vocabulary each token in to form a single-token candidate sequence , obtain a correctness score through introspection query construction, model forward propagation and scoring head calculation , and perform screening according to the correctness score to obtain a candidate token set ; The beam search module, configured to perform beam search on the candidate token set , and use the candidate token set Each token in the query is appended to the end of the currently retained candidate sequence in the global candidate pool, forming an extended candidate sequence. For each extended candidate sequence, an introspection query is reconstructed and the scorer is invoked to obtain its correctness score and progress score. The ranking score is calculated based on the correctness score and progress score. Based on the ranking score, the extended candidate sequence is selected as a retained candidate sequence and added to the global candidate pool. When the search meets the set stopping condition, the unique candidate sequence with the highest ranking score is selected from the global candidate pool as the recovery trigger word for the PEFT adapter to be audited.
[0072] The present invention provides a computing device, characterized in that it includes: a processor and a memory storing a computer program, wherein the computer program is executed by the processor to perform the above-described method.
[0073] The present invention provides a computer-readable storage medium, characterized in that it stores instructions that, when executed on a computer, cause the computer to perform the above-described method.
[0074] The above are preferred embodiments of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for targetless reverse recovery of backdoor trigger words in a large language model, comprising the following steps: Obtain a clean base large language model, several training PEFT adapters compatible with the clean base large language model and having known trigger words, and an auditable PEFT adapter compatible with the clean base large language model; wherein, the clean base large language model refers to the base large language model that has not been modified by the target backdoor implantation process; the training PEFT adapters are auxiliary backdoor adapters used for offline training of the scorer; Candidate sequences are constructed based on the known trigger words of each trained PEFT adapter, and correctness labels are set. and progress tags The candidate sequence sample is obtained; the correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a continuous prefix of the trigger word starting from the first position; the progress label indicates the proportion of the trigger word length that the candidate sequence has covered when it is a continuous prefix. A scorer is trained using the candidate sequence samples. The scorer includes a clean-base large language model, a currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multilayer perceptron scoring head. During offline training, the currently evaluated PEFT adapter is a trained PEFT adapter with known trigger words. The parameters of the clean-base large language model and the trained PEFT adapter are kept frozen, and only the parameters of the ITS LoRA adapter and the scoring head are updated, causing the scorer to output a correctness score for the candidate sequence. and progress score ; During the auditing phase, the currently evaluated PEFT adapter is replaced with the PEFT adapter to be audited, and the trained ITS LoRA adapter is simultaneously loaded onto the same clean-based large language model, reusing the trained scoring head; the complete vocabulary of the word segmenter accompanying the clean-based large language model is traversed. , complete vocabulary Each token Form a single token candidate sequence The correctness score is obtained through introspection query construction, model forward propagation, and score head calculation. Candidate token sets are obtained by filtering based on correctness scores. ; In candidate token set Perform a beam search to find the candidate token set. Each token in the query is appended to the end of the currently retained candidate sequence in the global candidate pool, forming an extended candidate sequence. For each extended candidate sequence, an introspection query is reconstructed and the scorer is invoked to obtain its correctness score and progress score. The ranking score is calculated based on the correctness score and progress score. Based on the ranking score, the extended candidate sequence is selected as a retained candidate sequence and added to the global candidate pool. When the search meets the set stopping condition, the unique candidate sequence with the highest ranking score is selected from the global candidate pool as the recovery trigger word for the PEFT adapter to be audited.
2. The method according to claim 1, characterized in that, No. During beam search, for the current beam Each candidate sequence in With candidate token set Each token in Construct an extended candidate sequence Calculate the extended candidate sequence Correctness score Progress score and sorting score u( (The one with the highest score is retained.) The extended candidate sequences form the next round bundle. .
3. The method according to claim 1, characterized in that, The trained PEFT adapter and the audited PEFT adapter are mounted on the same clean base large language model, enabling the scorer to learn triggering evidence that matches the hidden state space of the clean base large language model.
4. The method according to claim 1, characterized in that, For candidate sequences Correctness score Used to estimate candidate sequences Is it a valid trigger token for the current adapter or a consecutive trigger word prefix starting from the first one? Progress Score Used to estimate the proportion of consecutive trigger word prefixes that cover the complete trigger word; when training the scorer, a correctness loss is used. Constraint correctness score Using schedule loss Constraint schedule score loss of correctness Schedule loss Both use the binary cross-entropy loss function.
5. The method according to claim 1, characterized in that, The candidate sequence samples are packaged as chat templates and input into the scorer, so that the candidate sequence samples are in a context consistent with the reasoning habits of the clean-based large language model.
6. The method according to claim 1, 2, or 3, characterized in that, The scoring is an introspective trigger word scorer, which has a fixed introspective query template.
7. The method according to claim 1, characterized in that, Use recovery trigger words to perform backdoor auditing, risk reproduction, input filtering, online monitoring, or backdoor repair verification on the PEFT adapter to be audited.
8. A targetless reverse recovery system for backdoor-triggered words in a large language model, characterized in that, It includes a configuration module, a sample construction module, a scorer training module, an auditing module, and a beam search module; The configuration module is used to obtain a clean basic large language model, several training PEFT adapters compatible with the clean basic large language model and having known trigger words, and an auditable PEFT adapter compatible with the clean basic large language model; wherein, the clean basic large language model refers to the basic large language model that has not been modified by the target backdoor implantation process; the training PEFT adapter is an auxiliary backdoor adapter used for offline training of the scorer; The sample construction module is used to construct candidate sequences based on the known trigger words of each trained PEFT adapter and set correctness labels. and progress tags The candidate sequence sample is obtained; the correctness label indicates whether the candidate sequence is a single token in the trigger word of the current adapter, or whether it is a continuous prefix of the trigger word starting from the first position; the progress label indicates the proportion of the trigger word length that the candidate sequence has covered when it is a continuous prefix. The scorer training module is used to train a scorer using the candidate sequence samples. The scorer includes a clean-base large language model, a currently evaluated PEFT adapter, an ITS LoRA adapter for scoring, and a multilayer perceptron scoring head. During offline training, the currently evaluated PEFT adapter is a trained PEFT adapter with known trigger words. The parameters of the clean-base large language model and the trained PEFT adapter are kept frozen, and only the parameters of the ITS LoRA adapter and the scoring head are updated, so that the scorer outputs the correctness score of the candidate sequence. and progress score ; The audit module is configured to replace the currently evaluated PEFT adapter with the PEFT adapter to be audited, simultaneously load the trained ITS LoRA adapter on the same clean base large language model, and reuse the trained scoring head; traverse the complete vocabulary of the tokenizer supporting the clean base large language model , and use the complete vocabulary each token in to form a single-token candidate sequence , and obtain a correctness score through introspective query construction, model forward propagation and scoring head calculation , and perform screening according to the correctness score to obtain a candidate token set ; The beam search module is used to search the candidate token set. Perform a beam search to find the candidate token set. Each token in the query is appended to the end of the currently retained candidate sequence in the global candidate pool, forming an extended candidate sequence. For each extended candidate sequence, an introspection query is reconstructed and the scorer is invoked to obtain its correctness score and progress score. The ranking score is calculated based on the correctness score and progress score. Based on the ranking score, the extended candidate sequence is selected as a retained candidate sequence and added to the global candidate pool. When the search meets the set stopping condition, the unique candidate sequence with the highest ranking score is selected from the global candidate pool as the recovery trigger word for the PEFT adapter to be audited.
9. A computing device, characterized in that, include: A processor, a memory storing a computer program, wherein the computer program, when executed by the processor, performs the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A storage instruction that, when executed on a computer, causes the computer to perform the method as described in any one of claims 1 to 7.
