Method and system for detecting over-alignment degeneration of large language model
Patent Information
- Application Number
- CN202611005784.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而,现有技术中,安全对齐技术虽能提升拒答能力,却常引发过度对齐副作用,即非安全任务上的可用性、推理稳定性或表达丰富度下降,成为制约模型安全与业务能力平衡的关键问题
[0018]本说明书一些实施例提供的技术方案带来的有益效果至少包括:
Smart Images

Figure CN123011687A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology, specifically to a method and system for detecting over-alignment degradation in large language models. Background Technology
[0002] Large language models typically undergo a human preference alignment phase in the later stages of training. Common methods include reinforcement learning based on human feedback and direct preference optimization. These approaches employ harmful prompts to reject responses and adjust model parameters using preference datasets, enabling the model to produce compliant responses to sensitive inputs and meet security regulatory requirements. Existing research also addresses the evaluation of alignment effectiveness and side effects, such as sparse model difference analysis, behavioral alignment evaluation frameworks, and quantitative localization of alignment failures. However, these methods largely focus on security performance itself, lacking effective solutions for the systematic detection of non-security business capability degradation after alignment.
[0003] However, while existing secure alignment techniques can improve rejection rate, they often lead to over-alignment side effects, such as decreased usability, inference stability, or expressive richness on insecure tasks. This becomes a key issue restricting the balance between model security and business capabilities. The main technical shortcomings are: difficulty in stably identifying degradation dimensions. Conventional evaluations rely on independent scoring from benchmark sets such as GSM8K, HumanEval, and MMLU, but semantic overlap exists between tasks. For example, mathematical word problems involve both reading comprehension and arithmetic reasoning; directly classifying them into a single dimension leads to unclear sources of degradation and an inability to distinguish independent changes in coding, mathematical, and writing abilities. Random generation masks real drift: mechanisms such as temperature sampling cause different outputs from the same input. Multiple sampling and averaging or using a fixed random seed cannot effectively separate model changes from sampling variance, resulting in insufficient detection reliability. The detection results lack structured output interfaces: existing solutions only output total scores or manual conclusions, failing to convey crucial information such as degradation dimensions and magnitudes to compensation and repair systems or access control systems. Therefore, this application provides a method for achieving stable quantification, fine-grained localization, and structured output of degradation while eliminating random noise interference. Summary of the Invention
[0004] This specification describes a method and system for detecting over-alignment degradation in large language models through several embodiments.
[0005] Firstly, the embodiments of this specification provide a method for detecting excessive alignment degradation in large language models, including the following steps:
[0006] A multidimensional orthogonal core capability representation matrix is constructed. The representation matrix includes multiple low-correlation capability anchors. Each capability anchor corresponds to a non-security business capability dimension and is bound to a standard input, a reference output, and a corresponding scoring function. The representation matrix is generated by mapping candidate task samples to a semantic space and removing redundant samples with a correlation higher than a preset threshold.
[0007] Both the baseline version of the same large language model before and the test version after safe alignment are set to a deterministic greedy decoding mode with a temperature coefficient of 0. The prompt template and output length limit during inference are fixed. The standard input in the representation matrix drives the two versions to perform deterministic inference, and the first deterministic response and the second deterministic response are obtained respectively.
[0008] The first deterministic response and the second deterministic response are scored according to the scoring function. The capability values before and after alignment are obtained by aggregating by capability dimension. The relative drift rate of each dimension is calculated. Capability dimensions with a relative drift rate lower than a preset negative degradation threshold are marked as suspected degraded dimensions that are over-aligned. The detection results containing the degradation dimension identifier and drift magnitude are output.
[0009] Secondly, embodiments of this specification provide a detection system for over-alignment degradation in large language models, including:
[0010] The module constructs a representation matrix of multidimensional orthogonal core capabilities. The representation matrix includes multiple low-relevance capability anchors. Each capability anchor corresponds to a non-security business capability dimension and is bound to a standard input, a reference output, and a corresponding scoring function. The representation matrix is generated by mapping candidate task samples to a semantic space and removing redundant samples with relevance higher than a preset threshold.
[0011] The inference module sets both the baseline version of the same large language model before and the test version after safe alignment to a deterministic greedy decoding mode with a temperature coefficient of 0, and fixes the prompt template and output length limit during inference. The standard input in the representation matrix drives the two versions to perform deterministic inference, and obtains the first deterministic response and the second deterministic response respectively.
[0012] The detection module scores the first deterministic response and the second deterministic response according to the scoring function, aggregates the capability values before and after alignment of each dimension by capability dimension, calculates the relative drift rate of each dimension, marks capability dimensions with a relative drift rate lower than a preset negative degradation threshold as suspected degradation dimensions of overalignment, and outputs the detection results including degradation dimension identifier and drift magnitude.
[0013] Thirdly, embodiments of this specification provide an electronic device, including a processor and a memory;
[0014] The processor is connected to the memory;
[0015] The memory is used to store executable program code;
[0016] The processor runs a program corresponding to the executable program code stored in the memory to perform the method described in any of the above aspects.
[0017] Fourthly, embodiments of this specification provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the methods described in any of the above aspects.
[0018] The beneficial effects of the technical solutions provided in some embodiments of this specification include at least the following:
[0019] In several embodiments of this specification, a method and system for detecting over-alignment degradation in large language models are provided. Through the synergistic effect of a multi-dimensional orthogonal representation matrix, zero-temperature greedy decoding, and combined drift quantization, multiple beneficial effects are achieved. Regarding detection stability, the orthogonal representation matrix eliminates highly relevant redundant samples through semantic mapping, removing semantic crosstalk between different capability dimensions. Combined with a deterministic greedy decoding mode with zero temperature used in both the pre- and post-alignment models, random sampling noise is completely removed from drift calculations. This ensures that the difference in scores before and after alignment truly reflects the capability changes caused by safe alignment, significantly improving the verifiability and reliability of the detection and reducing the risk of false alarms.
[0020] In terms of positioning accuracy, each capability anchor point is bound to a clear dimension and scoring function, making the relative drift rate calculation accurate to various dimensions such as code generation, mathematical reasoning, and factual consistency. It can also drill down to the trigger anchor point level, providing accurate problem positioning basis for subsequent targeted governance.
[0021] In terms of engineering applications, the test results output structured data including degradation dimensions, drift amplitude, trigger anchor points and version identifiers, which can be directly connected to model online access control, regression testing pipeline or compensation and repair module to eliminate the information gap between the testing and remediation processes.
[0022] This invention provides a complete solution with high stability, fine granularity, and engineering interfaces for evaluating the side effects of over-alignment before deploying large language models.
[0023] Other features and advantages of various embodiments of this specification will be further revealed in the following detailed description and accompanying drawings. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this specification, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a schematic diagram of the over-alignment degradation detection method provided in this specification.
[0026] Figure 2 This is a schematic diagram of the scoring function processing provided in this manual.
[0027] Figure 3 This is a schematic diagram of the over-alignment degradation detection system provided in this specification.
[0028] Figure 4 This is a schematic diagram of the electronic device provided in this manual. Detailed Implementation
[0029] The technical solutions of the embodiments of this specification will be explained and described below with reference to the accompanying drawings. However, the following embodiments are only preferred embodiments of this specification and not all of them. Other embodiments obtained by those skilled in the art based on the embodiments in the implementation methods without creative effort are all within the protection scope of this specification.
[0030] The terms "first," "second," "third," etc., in the description, claims, and accompanying drawings are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.
[0031] In the following description, terms such as “inner,” “outer,” “upper,” “lower,” “left,” and “right” are used only to facilitate the description of the embodiments and to simplify the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this specification.
[0032] All data involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0033] Example 1
[0034] according to Figure 1 As shown, this embodiment provides a method for detecting over-alignment degradation in large language models. The method includes the following steps:
[0035] Step S1) Construct the representation matrix of multidimensional orthogonal core capabilities.
[0036] First, candidate task samples are extracted from publicly available benchmark datasets, enterprise historical logs, or manually annotated samples. These candidate task samples cover multiple non-security business capability dimensions, including code generation, mathematical reasoning, factual consistency, instruction compliance, long text organization, and creative expression. The candidate task samples are then input into a semantic vector encoding unit, and a pre-trained semantic encoding model is used to map each candidate task sample to a high-dimensional semantic space to obtain a corresponding semantic vector representation.
[0037] Then, the correlation analysis unit calculates the cosine similarity, covariance, or principal component projection relationship between different task clusters. For task clusters with correlation higher than a preset threshold, the orthogonal anchor point screening unit retains only representative samples and removes duplicate or highly coupled tasks. The preset threshold can be flexibly set according to the actual application scenario, for example, set to a cosine similarity greater than 0.80, 0.85, or 0.90. When the semantic similarity of two tasks exceeds this threshold, it indicates that the two are highly overlapping in the semantic space and may be examining the core capabilities of the same dimension. Therefore, only one representative task is retained as the anchor point for that dimension. For low-correlation task clusters that can respectively represent capabilities such as code generation, mathematical reasoning, factual consistency, instruction compliance, long text organization, and creative expression, that is, task clusters with a semantic vector cosine similarity lower than the preset threshold between different capability dimensions, they are solidified as capability anchor points. Each capability anchor point represents an independent core business capability dimension, and the anchor points maintain low correlation to ensure that the drift signals of different dimensions do not interfere with each other during subsequent degradation detection.
[0038] This results in a representation matrix M = {A_i, Q_ij, Yi_ij, S_ij}, where A_i represents the i-th capability dimension, Q_ij represents the j-th standard input under that dimension, Yi_ij represents the reference output or scoring rule corresponding to the standard input, used as a benchmark for evaluating the quality of the model response, and S_ij represents the scoring function of the anchor point, used to map the model response to a quantifiable score. The scoring function includes, but is not limited to, one or more combinations of rule matching scoring, model referee scoring, and unit test execution scoring.
[0039] Once the representation matrix is constructed, the matrix version number, anchor input, reference answer, scoring rules, and dimension weights are encapsulated for subsequent deterministic inference. The matrix version number identifies the version information of the representation matrix, facilitating traceability and comparison between different versions of the matrix; the dimension weights reflect the differences in the importance of different capability dimensions in the overall assessment during subsequent aggregation calculations.
[0040] As a specific implementation of this step, taking the enterprise customer service model as an example, the candidate samples simultaneously include tasks such as "calculating the refund amount according to the return rules," "explaining the restrictions of promotional activities," and "generating reassuring reply text for users." After the semantic vector encoding unit maps these tasks to the semantic space, the correlation analysis unit finds that the cosine similarity between "calculating the refund amount according to the return rules" and "explaining the restrictions of promotional activities" in the semantic vector space is 0.92, which is higher than the preset threshold of 0.85. Therefore, only one of them is retained as a representative sample. The correlation between "generating reassuring reply text for users" and the aforementioned tasks is 0.31, which is lower than the preset threshold, and it is retained independently. The orthogonal anchor point screening unit classifies the refund amount calculation into the mathematical / rule reasoning dimension, the explanation of promotional restrictions into the factual consistency and instruction compliance dimension, and the reassuring reply text into the long text organization and expression dimension, forming an orthogonal capability matrix covering multiple core business capabilities.
[0041] Step S2) Zero-temperature greedy decoding noise reduction and pre- and post-response acquisition.
[0042] In this step, the deterministic inference control module sets both the baseline version of the same large language model before and the test version after safe alignment to a deterministic greedy decoding mode with a temperature coefficient of 0. Specifically, the decoding parameter locking unit locks the inference parameters uniformly to Temperature=0 and uses greedy decoding to select the token with the highest conditional probability at each step. In natural language generation tasks, the temperature parameter controls the smoothness of the output probability distribution. A higher temperature (such as Temperature=0.8) makes the probability distribution flatter, increasing the likelihood of low-probability tokens being selected, thus introducing randomness; while Temperature=0 makes the probability distribution extremely sharp, and the model always selects the token with the highest conditional probability as the output at each decoding step, thus degenerating the entire generation process into a deterministic process, that is, the same input will inevitably produce the same output sequence under the same model weights and decoding parameters.
[0043] Simultaneously, the prompt template and output length limits during inference are fixed, specifically including fixed system prompt template, context window length, output terminator, and maximum output length. Fixing the system prompt template ensures that the model receives consistent pre-instructions during inference, avoiding output variations due to differences in prompt word expression; fixing the context window length ensures that the effective information range processed by the model is the same each time; fixing the output terminator ensures that the termination position of the model output is consistent; fixing the maximum output length ensures that the length range of the model output is the same, avoiding scoring bias due to differences in generation length. Fixing all the above inference parameters ensures that the output results for each anchor input under the same model version are stable and verifiable. The model version binding unit sequentially loads the pre-alignment model version and the post-alignment model version, using the standard input Q_ij in the representation matrix M to drive the two versions for deterministic inference, correspondingly obtaining the first deterministic response Response_before(i,j) and the second deterministic response Response_after(i,j).
[0044] After obtaining the first and second deterministic responses, the output normalization unit normalizes format noise, whitespace, unit representations, and code block boundaries without altering the semantic content. Specifically, format noise removal includes removing redundant newline characters, indentation characters, and special control characters; whitespace removal includes merging multiple consecutive spaces into a single space and removing leading and trailing whitespace; unit representation removal includes adding uniform spaces between numbers and units; and code block boundary removal includes standardizing the marking format of code segments. It is important to emphasize that the normalization process only affects the surface format of the response and does not change the semantic content or core information of the response, ensuring fairness and consistency in the subsequent scoring process.
[0045] The response caching unit caches Response_before(i,j) and Response_after(i,j) along with the model version identifier, decoding parameter identifier, and matrix version number, and passes them to subsequent steps. The model version identifier is used to distinguish between the baseline version and the version to be tested; the decoding parameter identifier records the specific parameter configuration used in this inference, including the temperature coefficient, prompt template version, output length limit, etc.; the matrix version number points to the representation matrix version used in this detection. The caching and transmission of the above information ensures the traceability and repeatability of the entire detection process.
[0046] As a specific implementation of this step, a code generation anchor requires the model to implement an array deduplication function with boundary conditions. Under a standard Temperature=0.8 sampling setting, the pre-alignment model might generate correct code once and miss handling empty arrays once; the post-alignment model might also exhibit similar fluctuations due to sampling differences. After adopting this step, both models generate unique responses under Temperature=0 conditions. If the post-alignment model stably adds irrelevant safety rejections or omits key logic, while the pre-alignment model stably passes unit tests, then this difference can serve as a reliable input for subsequent drift quantization.
[0047] Step S3) Capability drift quantification and over-alignment side effect determination.
[0048] In this step, the combined drift quantization decision engine receives the deterministic responses generated in step S102. The dimensional scoring unit first calls the scoring function S_ij bound to each capability anchor point to score the outputs corresponding to each anchor point in Response_before(i,j) and Response_after(i,j), respectively, to obtain the anchor-level scores Score_before(i,j) and Score_after(i,j). The specific implementation of the scoring process depends on the type of scoring function bound to each anchor point. For rule matching scoring, the system performs structured matching of the response based on a preset keyword list, regular expression, or format template; for model-judged scoring, the system calls a third-party judging model to comprehensively evaluate the response quality; for unit test execution scoring, the system executes the code in the response in an isolated environment and calculates the test case pass rate.
[0049] The anchor-level scores under the same capability dimension are weighted and aggregated according to the preset dimension weights of that dimension to obtain the capability value vector V_before=[Perf_before(1),Perf_before(2),…,Perf_before(n)] before alignment and the capability value vector V_after=[Perf_after(1),Perf_after(2),…,Perf_after(n)] after alignment, where n is the total number of capability dimensions.
[0050] The relative drift calculation unit calculates the relative drift rate for each dimension using the formula Δ_i = (Perf_after(i) - Perf_before(i)) / Perf_before(i), where Δ_i is the relative drift rate of the i-th capability dimension. A preset negative degradation threshold is -δ, where δ is a preset positive number representing the maximum allowable degradation magnitude. The dynamic threshold comparator compares the relative drift rate of each dimension with the preset negative degradation threshold. When the relative drift rate Δ_i of a certain capability dimension is less than -δ, it is determined that over-alignment degradation has occurred in that dimension.
[0051] Before marking suspected degraded dimensions, a verification step is also included: when the relative drift rate of a certain capability dimension is lower than the preset negative degradation threshold and the pass rate of the model on the safety-related rejection index does not deteriorate accordingly, the dimension is marked as a suspected degraded dimension of over-alignment; if the safety-related rejection index deteriorates simultaneously, the dimension is classified as insufficient safety alignment and is not marked as over-alignment.
[0052] The detection report generation unit outputs detection results that include degradation dimension identifiers and drift magnitudes. The detection results include at least the degradation dimension, degradation magnitude, trigger anchor point, decoding parameters, matrix version, and suggested governance interface.
[0053] As a specific implementation of this step, in a post-security alignment check, the system calculates the following dimensions: code generation Δ_code = -0.18, mathematical reasoning Δ_math = -0.04, factual consistency Δ_fact = -0.02, and writing expression Δ_write = -0.11, with a preset threshold δ = 0.08. The dynamic threshold comparator determines that the code generation dimension (-0.18 < -0.08) and writing expression dimension (-0.11 < -0.08) trigger degradation thresholds, while mathematical reasoning and factual consistency dimensions do not. Security-related rejection metrics show a pass rate of 96%, an improvement from 94% before alignment, without corresponding deterioration. Therefore, the detection report generation unit marks code generation and writing expression as potentially degraded dimensions due to over-alignment, and lists the trigger anchors, pre- and post-alignment responses, scoring functions, and zero-temperature decoding parameters in the report. It also recommends that only these two non-security capability dimensions undergo subsequent remediation or manual review.
[0054] Example 2
[0055] In this invention, the scoring function can employ one or more combinations of the following methods. Those skilled in the art should understand that different scoring methods can be selected for anchor points of different capability dimensions based on task type and evaluation requirements, and multiple scoring methods can be used in combination within the same testing process.
[0056] Please see the appendix Figure 2The scoring function is one or more combinations of rule matching score, model referee score, and unit test execution score:
[0057] Step S11) The rule matching score is based on the keywords, code execution results, format templates or logical assertions in the reference output, and performs structured matching on the model response and gives a score;
[0058] Step S12) The model referee scoring calls a third-party referee model to evaluate the consistency, correctness, and completeness between the model response and the reference output, and outputs a score;
[0059] Step S13) The unit test execution scoring targets the code generation class capability anchor point, executes the code snippets in the model response in an isolated environment using pre-set unit test cases, and calculates the score based on the test case pass rate.
[0060] Specifically, rule-based matching scoring: Rule-based matching scoring is based on keywords, code execution results, format templates, or logical assertions in the reference output. It performs structured matching on the model response and assigns a score. Rule-based matching scoring does not rely on external models and features high computational efficiency and strong determinism in scoring results. Specifically, for anchor points in the factual consistency dimension, a list of key fact entities in the reference answer can be preset. The model response is then matched precisely or fuzzily with this list, and a score is calculated based on the matching rate. For example, when answering the question "What is the capital of China?", the preset key fact entity is "Beijing." If the model response contains the word "Beijing," it receives full marks; otherwise, no marks are awarded. For anchor points in the format compliance category, a preset format template can be used. For example, the model is required to output data containing three fields: "name," "age," and "city" in JSON format. Scoring checks whether the model response conforms to the preset JSON structure, and scores are calculated based on field completeness and format correctness. For anchor points in the logical assertion category, a preset logical expression or assertion statement can be used. Scoring determines whether the conclusion in the model response meets preset logical conditions, such as determining the correctness of the final calculation result in a math word problem.
[0061] Model-based judging: The model-based judging process calls a third-party judging model to evaluate the consistency, correctness, and completeness of the model response with the reference output, and outputs a score. Model-based judging is suitable for open-ended or creative tasks that are difficult to quantify precisely using rules, such as writing and creative expression, and idea generation. Specifically, the standard input Q_ij, the reference output Y_ij, and the model response Response are constructed together as judging prompts. The judging prompts explicitly require the judging model to score from multiple evaluation dimensions, such as logical coherence, language fluency, information completeness, and consistency with the reference output. The judging model can be GPT-4, Claude-3, or other large language models with strong judging capabilities. The score range for each dimension is 0 to 10 or 0 to 100 points, and the final score can be the weighted sum or average of the dimensions. To ensure consistency and fairness in scoring, the same response can be judged multiple times and the average can be taken, or multiple different judging models can be used for cross-validation.
[0062] Unit Test Execution Scoring: This scoring targets code generation capability anchors. It involves executing pre-defined unit test cases on code snippets from the model response in an isolated environment, and calculating a score based on the pass rate of these test cases. Specifically, code snippets are extracted from the model response, compiled and executed in a Docker container or sandbox environment using a pre-defined set of unit test cases. The percentage of successful test cases out of the total number of test cases is used as the score for that anchor. For example, for the code generation anchor of an array deduplication function, the pre-defined unit test cases include boundary conditions such as empty array input, array input containing duplicate elements, and sorted array input. The pass rate directly reflects the correctness of the generated code.
[0063] Example 2
[0064] according to Figure 2 As shown, this embodiment provides a detection system for over-alignment degradation in large language models. It includes:
[0065] Module 100 is used to construct a representation matrix of multidimensional orthogonal core capabilities. The representation matrix includes multiple low-relevance capability anchors, each corresponding to a non-security business capability dimension, and is bound to a standard input, a reference output, and a corresponding scoring function. The representation matrix is generated by mapping candidate task samples to a semantic space and removing redundant samples with relevance exceeding a preset threshold. Specifically, the module includes a task sample acquisition unit, a semantic vector encoding unit, a relevance analysis unit, an orthogonal anchor selection unit, and a standard input / output pair encapsulation unit. The task sample acquisition unit extracts candidate tasks from public benchmarks, enterprise historical logs, or manually labeled samples; the semantic vector encoding unit maps candidate task samples to a high-dimensional semantic space; the relevance analysis unit calculates the cosine similarity, covariance, or principal component projection relationship between different task clusters; the orthogonal anchor selection unit removes duplicate or highly coupled tasks according to a preset relevance threshold; and the standard input / output pair encapsulation unit encapsulates the matrix version number, anchor input, reference answer, scoring rules, and dimension weights.
[0066] The inference module 200 sets both the baseline version of the same large language model before and after safe alignment to a deterministic greedy decoding mode with a temperature coefficient of 0. It also fixes the prompt template and output length limit during inference, using the standard input from the representation matrix to drive deterministic inference for both versions, thereby obtaining a first deterministic response and a second deterministic response. Specifically, the inference module includes a decoding parameter locking unit, a model version binding unit, a response caching unit, and an output normalization unit. The decoding parameter locking unit locks the inference parameters uniformly to Temperature=0 and uses a greedy decoding strategy to select the token with the highest conditional probability at each step. It also fixes the system prompt template, context window length, output terminator, and maximum output length. The model version binding unit loads the weight files of the pre-alignment and post-alignment model versions sequentially, ensuring that both versions perform inference under the same model architecture. The response caching unit stores Response_before(i,j) and Response_after(i,j) and their corresponding metadata, including model version identifier, decoding parameter identifier, and matrix version number, for subsequent steps to call and trace. The output normalization unit normalizes format noise, whitespace, unit expressions, and code block boundaries to ensure format consistency between different responses while ensuring that normalization does not change the semantic content.
[0067] The detection module 300 is used to score the first deterministic response and the second deterministic response according to the scoring function, aggregate the capability values before and after alignment of each dimension by capability dimension, calculate the relative drift rate of each dimension, mark the capability dimensions with a relative drift rate lower than a preset negative degradation threshold as suspected degradation dimensions of over-alignment, and output the detection result including the degradation dimension identifier and drift magnitude. The detection module specifically includes the following five functional units: a dimensional scoring unit, which calls the scoring function bound to each capability anchor point to score the responses before and after each anchor point and generate an anchor point-level score matrix; a relative drift calculation unit, which weights and aggregates the anchor point-level scores into dimensional capability values according to dimensional weights and calculates the relative drift rate of each dimension; a random noise elimination and marking unit, which marks responses that have eliminated random sampling noise under deterministic inference conditions to ensure that the drift calculation results do not contain sampling variance components; a dynamic threshold comparator, which compares the relative drift rate of each dimension with a preset negative degradation threshold and, in conjunction with the verification results of the safety-type rejection index, generates a judgment conclusion on whether each dimension has undergone excessive alignment degradation; and a detection report generation unit, which outputs a structured detection report containing the degradation dimension, degradation magnitude, trigger anchor point, decoding parameters, matrix version, and suggested governance interface.
[0068] Example 4
[0069] Some steps of the present invention can be implemented using various alternative solutions, which are described below.
[0070] Alternatives to the orthogonalization method: In the above embodiments, the orthogonalization method uses cosine similarity-based correlation analysis combined with a preset threshold for anchor point selection. In alternative implementations, the orthogonalization method can employ Principal Component Analysis (PCA), Independent Component Analysis (ICA), cluster decorrelation, manual label constraints, or a combination of multiple methods. For example, when using PCA, the semantic vectors of candidate task samples are used to construct a matrix, and principal component decomposition is performed. The task sample with the highest loading in the principal component direction is selected as the representative anchor point for each capability dimension. When using cluster decorrelation, the semantic vectors of candidate task samples are clustered, and samples near the center point of each cluster are selected as anchor points to ensure low correlation between different clusters.
[0071] Alternatives to deterministic reasoning: In the above embodiments, deterministic reasoning employs greedy decoding with a temperature coefficient of 0. In alternative implementations, zero-temperature greedy decoding can also be used in conjunction with a fixed random seed, a fixed prompt template, and fixed output normalization rules. Specifically, based on setting Temperature=0, the random seed is further fixed to a specific value, such as seed=42, to ensure that the random sequence remains consistent throughout any inference process involving random number generation. Simultaneously, the system prompt template is fixed to a uniform format, for example, uniformly using "You are an intelligent assistant, please answer the following questions:" as the system prompt prefix to avoid output deviations caused by differences in prompt wording. The combined use of these multiple deterministic measures can further reduce output differences between different operating environments, different batch processing orders, or different deployment instances, making the detection conclusions more verifiable.
[0072] Alternative scoring functions: In the above embodiments, the scoring function employs rule-matching scoring, model-judged scoring, or unit testing. In alternative implementations, the scoring function can also employ manual annotation scoring or a weighted combination of the above methods. Manual annotation scoring is suitable for evaluation scenarios requiring subjective judgment, such as when evaluating the richness of creative expression or the strength of emotional resonance. Multiple annotators can score the model response, and the average score can be taken as the final score. A weighted combination of multiple methods can assign different weights to different scoring methods based on the specific characteristics of each anchor point. For example, for anchor points with both format and content requirements, rule-matching scoring can be used to assess format compliance (weight 40%), model-judged scoring can be used to assess content quality (weight 60%), and then the two weighted sums can be used as the final score.
[0073] Alternative solutions for subsequent governance: In the above embodiments, the detection report can optionally be passed to the subsequent governance module. In alternative implementations, the detection report can optionally be passed to the non-intrusive LoRA compensation module, the security hard circuit breaker verification module, or the manual review module, but the above compensation modules are not a necessary condition for completing degradation detection. For example, when the detection report marks a degradation in the code generation dimension, the degradation dimension and trigger anchor point information can be passed to the LoRA compensation module. The LoRA compensation module only performs targeted compensation training for code generation capabilities, without the need for full retraining. The security hard circuit breaker verification module refers to the circuit breaker mechanism that automatically triggers the online access control when the detection report shows that multiple capability dimensions have suffered severe degradation, preventing the current security-aligned version from being deployed online, and notifying operations personnel for manual review. The manual review module refers to sending the detection report to the quality assurance team or model development team, whereby humans conduct a secondary confirmation of the degradation dimension and trigger anchor point, and decide on the subsequent processing plan.
[0074] Example 5
[0075] Please see Figure 4 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this specification.
[0076] according to Figure 4 As shown, the electronic device 1100 may include: at least one processor 1101, at least one network interface 1104, a user interface 1103, a memory 1105, and at least one communication bus 1102. The communication bus 1102 can be used to connect and communicate with the various components mentioned above. The user interface 1103 may include buttons, and optionally may include standard wired or wireless interfaces. The network interface 1104 may include, but is not limited to, a Bluetooth module, an NFC module, or a Wi-Fi module. The processor 1101 may include one or more processing cores. The processor 1101 connects to various parts within the electronic device 1100 using various interfaces and lines, and performs various functions of the routing device and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1105, and by calling data stored in the memory 1105. Optionally, the processor 1101 may be implemented using at least one hardware form of DSP, FPGA, or PLA. The processor 1101 may integrate one or more combinations of CPU, GPU, and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content that the display screen needs to show; and the modem is used for wireless communication.
[0077] It is understandable that the aforementioned modem may not be integrated into the processor 1101, but may be implemented using a separate chip.
[0078] The memory 1105 may include RAM or ROM. Optionally, the memory 1105 may include a non-transitory computer-readable medium. The memory 1105 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 1105 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 1105 may also be at least one storage device located remotely from the aforementioned processor 1101. As a computer storage medium, the memory 1105 may include an operating system, a network communication module, a user interface module, and application programs. The processor 1101 may be used to call the application programs stored in the memory 1105 and execute the methods in the above-described embodiments.
[0079] This specification also provides a computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform multiple steps as described in the above embodiments. If the constituent modules of the above-described electronic device are implemented as software functional units and sold or used as independent products, they can be stored in the computer-readable storage medium.
Claims
1. A method for detecting over-alignment degradation in large language models, characterized in that, Including the following steps: A multidimensional orthogonal core capability representation matrix is constructed. The representation matrix includes multiple low-correlation capability anchors. Each capability anchor corresponds to a non-security business capability dimension and is bound to a standard input, a reference output, and a corresponding scoring function. The representation matrix is generated by mapping candidate task samples to a semantic space and removing redundant samples with a correlation higher than a preset threshold. Both the baseline version of the same large language model before and the test version after safe alignment are set to a deterministic greedy decoding mode with a temperature coefficient of 0. The prompt template and output length limit during inference are fixed. The standard input in the representation matrix drives the two versions to perform deterministic inference, and the first deterministic response and the second deterministic response are obtained respectively. The first deterministic response and the second deterministic response are scored according to the scoring function. The capability values before and after alignment are obtained by aggregating by capability dimension. The relative drift rate of each dimension is calculated. Capability dimensions with a relative drift rate lower than a preset negative degradation threshold are marked as suspected degraded dimensions that are over-aligned. The detection results containing the degradation dimension identifier and drift magnitude are output.
2. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, The data structure of the representation matrix is defined as M={Ai,Qij,Yij,Sij}, where Ai represents the i-th capability dimension, Qij represents the j-th standard input under this dimension, Yij represents the reference output or scoring rule corresponding to the standard input, and Sij represents the scoring function of the anchor point. The non-security business capability dimensions include one or more of the following: code generation, mathematical reasoning, factual consistency, instruction compliance, long text organization, and creative expression.
3. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, The fixed inference prompt template and output length limit specifically include the fixed system prompt template, context window length, output terminator, and maximum output length; After obtaining the first deterministic response and the second deterministic response, the method further includes a step of normalizing format noise, whitespace, unit expressions, and code block boundaries, wherein the normalization process does not change the semantic content.
4. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, After obtaining the first deterministic response and the second deterministic response, the first deterministic response, the second deterministic response, along with the model version identifier, the decoding parameter identifier, and the matrix version number, are cached together and passed to subsequent steps.
5. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, Before marking capability dimensions with relative drift rates below a preset negative degradation threshold as suspected degradation dimensions, a verification step is also included: When the relative drift rate of a certain capability dimension is lower than the preset negative degradation threshold, and the pass rate of the model on the safety-related rejection index does not deteriorate accordingly, the dimension is marked as a suspected degraded dimension that is over-aligned. If security-related rejection metrics deteriorate simultaneously, this dimension will be classified as insufficient security alignment and will not be marked as over-alignment.
6. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, Methods for aggregating by capability dimension to obtain the capability values before and after alignment for each dimension include: First, the scoring function bound to each capability anchor point is called to score the output corresponding to each anchor point in the first deterministic response and the second deterministic response, respectively, to obtain the score at each anchor point level; The anchor-level scores under the same capability dimension are weighted and aggregated according to the preset dimension weights of that dimension to obtain the capability value vector V_before=[Perf_before(1),Perf_before(2),...,Perf_before(n)] before alignment and the capability value vector V_after=[Perf_after(1),Perf_after(2),...,Perf_after(n)] after alignment, where n is the total number of capability dimensions; The relative drift rate is calculated as Δ_i=(Perf_after(i)-Perf_before(i)) / Perf_before(i), where Δ_i is the relative drift rate of the i-th capability dimension; The preset negative degradation threshold is -δ, where δ is a preset positive number representing the maximum allowable degradation magnitude. When the relative drift rate Δ_i of a certain capability dimension is less than -δ, it is determined that the dimension has undergone over-alignment degradation.
7. The method for detecting over-alignment degradation in large language models according to claim 1, characterized in that, The scoring function is one or more combinations of rule matching scoring, model referee scoring, and unit test execution scoring: The rule matching score is based on keywords, code execution results, format templates, or logical assertions in the reference output, and performs structured matching on the model response and gives a score. The model referee scoring calls a third-party referee model to evaluate the consistency, correctness, and completeness between the model response and the reference output, and outputs a score; The unit test execution score targets the code generation class capability anchor point, executes pre-set unit test cases in an isolated environment using code snippets from the model response, and calculates a score based on the pass rate of the test cases.
8. A detection system for over-alignment degradation in large language models, characterized in that, include: The module constructs a representation matrix of multidimensional orthogonal core capabilities. The representation matrix includes multiple low-relevance capability anchors. Each capability anchor corresponds to a non-security business capability dimension and is bound to a standard input, a reference output, and a corresponding scoring function. The representation matrix is generated by mapping candidate task samples to a semantic space and removing redundant samples with relevance higher than a preset threshold. The inference module sets both the baseline version of the same large language model before and the test version after safe alignment to a deterministic greedy decoding mode with a temperature coefficient of 0, and fixes the prompt template and output length limit during inference. The standard input in the representation matrix drives the two versions to perform deterministic inference, and obtains the first deterministic response and the second deterministic response respectively. The detection module scores the first deterministic response and the second deterministic response according to the scoring function, aggregates the capability values before and after alignment of each dimension by capability dimension, calculates the relative drift rate of each dimension, marks capability dimensions with a relative drift rate lower than a preset negative degradation threshold as suspected degradation dimensions of overalignment, and outputs the detection results including degradation dimension identifier and drift magnitude.
9. An electronic device, characterized in that, Including the processor and memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code stored in the memory to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.
