Quantitative training method and device for multi-mode malicious software detection model
By utilizing cross-modal shared activation quantization scaling factor and gradient error compensation techniques during the quantization training of the multimodal malware detection model, the problem of accuracy degradation during quantization is solved, achieving high accuracy malware detection even with low precision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-03
AI Technical Summary
Existing multimodal malware detection models suffer from performance loss and accuracy degradation during quantization, especially at low precision quantization. Important feature information is often lost in multimodal data fusion tasks, affecting the accuracy of detection results.
By acquiring the joint statistical information of activation values generated by multiple modal data during model forward propagation, a cross-modal activation quantization scaling factor is determined. The activation values output by each modal branch are pseudo-quantized, and the gradient error introduced by the pseudo-quantization operation is compensated during backpropagation to update the model parameters until the model converges.
It reduces additional errors caused by inconsistent quantization scales during the quantization process, improves the classification accuracy of the quantization model, and enables the malware detection model to have high accuracy even at low precision.
Smart Images

Figure CN121786488A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence, machine learning, and cybersecurity, and in particular to a quantitative training method and apparatus for a multimodal malware detection model. Background Technology
[0002] Existing deep learning models have made significant progress in handling multimodal tasks, particularly in malware detection. With increased computing power and data volume, multimodal learning has become a key technology for improving model performance. However, malware detection models still face numerous challenges when deployed in real-world environments. One of the most prominent issues is the performance loss during quantization. To improve inference speed and deployment efficiency, especially on resource-constrained devices, low-precision quantization is used to reduce computational overhead and memory usage. However, low-precision quantization often leads to a decrease in accuracy, particularly in interpretable models, where it can significantly impact the reliability of the model's output.
[0003] Currently, common quantization methods mainly focus on traditional single-modal tasks, and their adaptability is poor for complex multimodal tasks. In low-precision quantization processes, especially for multimodal data fusion tasks, some important feature information is often lost, affecting the final detection results and the accuracy of the model. Summary of the Invention
[0004] This invention provides a method and apparatus for quantitative training of a multimodal malware detection model. The technical solution is as follows: On the one hand, a quantitative training method for a multimodal malware detection model is provided, the method comprising: During the quantitative training of the malware detection model, multiple modalities of input data are acquired; By utilizing the joint statistical information of activation values generated by multiple modal data during model forward propagation, the activation quantization scaling factor shared across modalities is determined. The activation value output by each modal branch is pseudo-quantized using the activation quantization scaling factor to generate quantized multimodal features. The model loss is calculated based on the multimodal features in forward inference, and the gradient error introduced by the pseudo-quantization operation is compensated during backpropagation to update the model parameters. Repeat the above steps until the model converges to obtain the quantized model.
[0005] On the other hand, a quantization training device for a multimodal malware detection model is provided, the device comprising: The acquisition unit is used to acquire multiple modal data during the quantization training of the malware detection model. The determination unit is used to determine the activation quantization scaling factor shared across modalities by utilizing the joint statistical information of activation values generated by multiple modal data during model forward propagation. The processing unit is used to perform pseudo-quantization processing on the activation value output by each modal branch using the activation quantization scaling factor to generate quantized multimodal features. The compensation unit is used to calculate the model loss based on the multimodal features in forward inference and to compensate for the gradient error introduced by the pseudo-quantization operation during backpropagation in order to update the model parameters; the acquisition unit, determination unit, processing unit and compensation unit are repeatedly triggered to perform corresponding operations until the model converges and the quantized model is obtained.
[0006] On the other hand, a computer device is provided, the computer device including a memory and a processor, the memory for storing computer programs, and the processor for executing the computer programs stored in the memory to implement the steps of the quantitative training method for the multimodal malware detection model described above.
[0007] On the other hand, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, the steps of the quantization training method for the multimodal malware detection model described above are implemented.
[0008] On the other hand, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the quantitative training method for the multimodal malware detection model described above.
[0009] The technical solution provided by this invention can bring at least the following beneficial effects: In the quantization training process of a multimodal malware detection model, the joint statistical information of activation values generated during forward propagation is used to determine a shared activation quantization scaling factor across modalities. Multiple modal branches use the same activation quantization scaling factor for pseudo-quantization. Even though quantization introduces errors, because multiple modalities use the same quantization benchmark, their outputs are mapped to the same low-precision numerical space. This reduces additional errors caused by inconsistent quantization scales when subsequent feature fusion is used to generate multimodal features. Furthermore, by compensating for gradient errors introduced by pseudo-quantization during backpropagation, the accuracy loss during quantization can be effectively reduced. Based on this, the present invention can improve the classification accuracy of the quantization model, enabling the malware detection model to achieve high accuracy even at low precision. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart of a quantitative training method for a multimodal malware detection model provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of a model quantization training process provided in an embodiment of the present invention; Figure 3 This is a structural diagram of a quantization training device for a multimodal malware detection model provided in an embodiment of the present invention; Figure 4 This is a hardware architecture diagram of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0013] Please refer to Figure 1 This invention provides a method for quantizing and training a multimodal malware detection model, the method comprising: Step 100: During the quantization training of the malware detection model, acquire multiple modal data from the input; Step 102: Determine the activation quantization scaling factor shared across modalities by using the joint statistical information of activation values generated by multiple modal data during model forward propagation. Step 104: Use the activation quantization scaling factor to perform pseudo-quantization on the activation value output of each modal branch to generate quantized multimodal features; Step 106: Calculate the model loss based on the multimodal features in forward inference, and compensate for the gradient error introduced by the pseudo-quantization operation during backpropagation to update the model parameters; Step 108: Repeat the above steps until the model converges to obtain the quantized model.
[0014] In this embodiment of the invention, during the quantization training of the multimodal malware detection model, the joint statistical information of the activation values generated during the model's forward propagation is used to determine a shared activation quantization scaling factor across modalities. Multiple modal branches use the same activation quantization scaling factor for pseudo-quantization. Even though quantization introduces errors, because multiple modalities use the same quantization benchmark, the outputs of multiple modalities are mapped to the same low-precision numerical space. This reduces additional errors caused by inconsistent quantization scales when subsequent feature fusion is used to generate multimodal features. Furthermore, by compensating for the gradient errors introduced by the pseudo-quantization operation during backpropagation, the accuracy loss during quantization can be effectively reduced. Therefore, this invention can improve the classification accuracy of the quantization model, enabling the malware detection model to have high accuracy even at low precision.
[0015] The following description Figure 1 The execution method for each step is shown.
[0016] First, for step 100, during the quantization training of the malware detection model, multiple modal data of the input are acquired.
[0017] In this embodiment of the invention, the malware detection model is a multimodal model, which is used to perform inference based on multiple modal data input to output inference results.
[0018] In one implementation, the input modal data includes at least: image modal data and text modal data; the image modal data is obtained based on software binary file encoding; the text modal data is generated based on security context information.
[0019] In one implementation, the output reasoning result includes at least a classification result. This classification result can be binary, ternary, or fine-grained classification.
[0020] In another implementation, the output inference result also includes at least one of the following: structured explanatory text and confidence score. The structured explanatory text explains the model's detection decisions in structured text form, providing a human-readable reasoning process, and may include family tags, attack behaviors, threat indicators, etc.; where family tags refer to the specific family or variant to which the malware belongs; and the confidence score quantifies the model's confidence in its own predictions, reflecting the reliability of the predictions.
[0021] The following example, using image modal data and text modal data as input, illustrates how to acquire multiple modal data.
[0022] First, the image modal data is acquired in the following way: A1: Determine the mapping relationship between binary bytes and image pixels; In this embodiment of the invention, the mapping relationship between binary bytes and image pixels can include single-channel mapping and multi-channel mapping. Single-channel mapping encodes one byte into one pixel; multi-channel mapping encodes multiple bytes (three bytes for RGB channels and four bytes for RGBA channels) into one pixel.
[0023] A2: Determine the encoding method for structural information; In one embodiment of the present invention, the structural information includes: segment information and / or high-entropy regions.
[0024] In this embodiment of the invention, the structure of a binary file typically includes multiple distinct parts, such as code segments and data segments, each referred to as a segment. The location and content of segments within the binary file are crucial for malware identification. In this embodiment of the invention, by preserving segment information and optimizing it through an attention mechanism, the malware detection system can better understand the structural characteristics of the binary file.
[0025] In one implementation, segment information includes segment boundaries. Segment boundaries are physical separation points between different segments in a binary file, used to distinguish different parts of the binary file. In another implementation, segment information also includes segment types. Segment types can include: .text segment, .data segment, .bss segment, .rodata segment, .stack segment, and .heap segment.
[0026] High-entropy regions typically contain complex or random content and are often associated with malicious behavior. In this embodiment of the invention, high-entropy regions of the binary file are determined by calculating the byte probability distribution of each window region in the binary file one by one. The attention mechanism is optimized by extracting entropy features to accurately identify key parts of malicious files.
[0027] It is understandable that the encoding methods for structural information include the encoding of segmental information and the encoding methods for high-entropy regions.
[0028] Specifically, the segment information is encoded in at least one of the following ways: each segment occupies a different area in the encoded image; different segments are distinguished by pixel intervals or line intervals; and different segment types are encoded using different colors.
[0029] Encoding high-entropy regions can be achieved by setting the pixel positions of the encoded image corresponding to the byte range of the high-entropy region in the binary file as specific feature markers. These feature markers include specific colors and / or specific shapes. This allows the malware detection model to focus more on these high-entropy regions during training, improving the accuracy of malware detection.
[0030] A3: Encode the byte sequence in the binary file into the image according to the mapping relationship and encoding method to obtain the encoded image; It should be noted that, in order to ensure the structural fidelity of the binary file content, in one embodiment of the present invention, the line width of the encoded image corresponding to different binary files is adaptively obtained based on the size and structure of the binary file. The line width of the encoded image is the minimum value that can carry the binary file, and the line width is within a preset line width range. Furthermore, the size of the encoded image satisfies a preset aspect ratio. In this way, the loss of important information caused by a fixed line width can be avoided.
[0031] The encoded image obtained is used as the image modality data in the embodiments of the present invention.
[0032] Then, the text modal data is obtained as follows: the security context of the current quantization training phase is obtained, and the security context is used as the text modal data. The security context includes at least one or more of the following: threat intelligence summary, recent detection results, family characteristics related to malware, and historical information related to malware. The threat intelligence summary may include known characteristics, attack groups, industry trends, etc.; recent detection results may include alerts, correlation data, sandbox analysis, etc.; family characteristics may include behavior, code, structure, etc.; and historical information may include infection, handling, and propagation information, etc.
[0033] Multiple modal data are input into the malware detection model so that during the quantization training process, the malware detection model performs feature extraction and feature fusion for each modal data, and uses the fused features to output the inference results.
[0034] Then, for step 102, "using the joint statistical information of the activation values generated by multiple modal data in the forward propagation of the model to determine the activation quantization scaling factor shared across modalities" and step 104, "using the activation quantization scaling factor to perform pseudo-quantization processing on the activation values output by each modal branch to generate quantized multimodal features".
[0035] In this embodiment of the invention, since the malware detection model is a multimodal model and the input is multiple modal data, the internal architecture of the malware detection model includes at least multiple modal branches that correspond one-to-one with the multiple modal data. The modal branches are used to extract features from the corresponding modal data. The malware detection model also includes a fusion layer, and the outputs of the multiple modal branches are all connected to the fusion layer.
[0036] Please refer to Figure 2 This is a schematic diagram of the model quantization training process according to an embodiment of the present invention. After inputting multiple modal data, a forward propagation phase is first performed for character alignment.
[0037] Specifically, in this forward propagation stage, full-precision feature extraction is performed first. By calculating the activation quantization scaling factor shared across modalities, the activation values output by each modal branch are subjected to consistent pseudo-quantization processing using this activation quantization scaling factor. The aligned features are then fed into the fusion layer to generate quantized multimodal features.
[0038] In one embodiment of the present invention, determining the cross-modal shared activation quantization scaling factor using the joint statistical information of activation values generated by multiple modal data during model forward propagation may specifically include: Step 1020: Before the preset fusion layer, obtain the activation value tensor of each modal branch output; Step 1022: Calculate the joint numerical distribution of the activation value tensors of multiple modes; Step 1024: Calculate the activation quantization scaling factor based on the joint numerical distribution.
[0039] Furthermore, in a more preferred embodiment, the activated quantization scaling factor satisfies at least one of the following constraints: computational location constraint, shared range constraint, and dynamic update constraint.
[0040] In the computational position constraint, the activation quantization scaling factor is calculated in the multimodal model before the preset fusion layer, which is the position where the multimodal features first interact, including but not limited to the splicing layer, cross-attention layer or gated fusion layer.
[0041] In the shared range constraint, within the same training iteration, for all modal branches prior to the fusion layer, only one activation quantization scaling factor is calculated, and this activation quantization scaling factor is simultaneously applied to the activation value quantization process of all modal branches.
[0042] In dynamic update constraints, the activation quantization scaling factor is not a static constant, but is dynamically updated in each training iteration based on the joint statistical information of the activation values of each modality in the current batch.
[0043] By using the above constraints, we can avoid different modalities being mapped to different low-precision numerical spaces due to scale inconsistencies during the quantization process, thereby reducing the additional quantization errors introduced during multimodal feature fusion.
[0044] Taking image modality data and text modality data as an example, assuming the floating-point activation value tensor output by the image modality branch is A_img with shape [B, C_img], and the floating-point activation value tensor output by the text modality branch is A_text with shape [B, C_text], then the calculation of the joint numerical distribution essentially involves aggregating and statistically analyzing the values of the two tensors. This can be done primarily through the following methods: Method 1: Statistics after tensor concatenation Specifically, the activation value tensors of multiple modalities can be concatenated along the channel dimension to obtain a joint tensor; the statistics of the joint tensor can be calculated to characterize the joint numerical distribution.
[0045] The joint numerical distribution concatenates A_img and A_text to form a joint tensor A_joint, on which the required statistics are computed. These statistics can be at least one of the following: maximum, minimum, mean, and standard deviation.
[0046] In one implementation, when calculating the activation quantization scaling factor using statistics, the following formula can be used: S=(max_val-min_val) / (quant_max-quant_min) Where S is the activation quantization scaling factor, max_val and min_val are the maximum and minimum values, respectively, and quant_max and quant_min are the maximum and minimum endpoints of the target integer range, respectively. The target integer range is, for example, [-128, 127] of INT8.
[0047] Method 2: Statistical Analysis Based on Alignment Features Specifically, activation value tensors of multiple modalities can be input into the feature alignment module to obtain aligned fused feature tensors. The statistics of the fused feature tensors are then calculated as joint numerical distributions.
[0048] In addition to the two methods mentioned above, other methods can also be used, such as weighted aggregate statistics.
[0049] Furthermore, when there are only two modal data, the joint numerical distribution can also be a numerical statistics performed on the activation value tensor of each modality, which can be at least one of the sum, maximum value, minimum value, mean, and standard deviation.
[0050] In one implementation, when using numerical statistics to calculate the activation quantization scaling factor, the following formula can be used: S = (sum_img) / (sum_text) Where S is the activation quantization scaling factor, and sum_img and sum_text are the summation values of the image modality and the text modality, respectively.
[0051] In this embodiment of the invention, regardless of the method used to calculate the activation quantization scaling factor, the goal is to obtain a scaling factor that simultaneously adapts to multiple modal data.
[0052] After calculating the activation quantization scaling factor, pseudo-quantization is performed on each modal branch using the same activation quantization scaling factor.
[0053] Specifically, the activation value output by each modal branch is pseudo-quantized using the activation quantization scaling factor, including: quantizing the floating-point activation value output by each modal branch using the same activation quantization scaling factor to obtain a simulated integer value; and dequantizing the integer value to convert it into a floating-point number with error.
[0054] Taking image modality and text modality as examples, the quantization formula is: Q img = clamp ( round ( X img / S + Z ), Q min , Q max ) Q text = clamp ( round ( X text / S + Z ), Q min , Q max ) in, Q img , Q text These are integer values for the image modality and the text modality, respectively. clamp() For the floor function, round() This is a truncation function. X img , X text , where S is the floating-point activation value for the image modality and Z is the text modality, respectively; S is the activation quantization scaling factor; and Z is the zero point. Q min , Q max These are the minimum and maximum values corresponding to the target integer bit width, respectively.
[0055] Taking image modality and text modality as examples, the inverse quantization formula is: in, X’ img , X’text These are floating-point numbers with errors for the image modality and the text modality, respectively.
[0056] The converted floating-point number with error is the quantized multimodal feature. The converted floating-point number with error is input into the fusion layer for feature fusion to obtain the fused feature.
[0057] It's important to note that multiple modal branches use the same mathematical formulas and parameters. Therefore, even though quantization introduces errors, because multiple modalities use the same quantization benchmark, they are mapped to the same low-precision numerical space. This reduces additional errors caused by inconsistent quantization scales during subsequent feature fusion, such as interactive computation in cross-attention layers.
[0058] In this embodiment of the invention, by transforming the calculation of the activation quantization scaling factor from an independent, static process into a cross-modal, dynamic process, and integrating it into the training loop of the quantization training process, the accuracy retention capability of the multimodal model after quantization is improved.
[0059] Next, for step 106, forward inference is performed based on the multimodal features to calculate the model loss, and the gradient error introduced by the pseudo-quantization operation is compensated during backpropagation to update the model parameters.
[0060] See also Figure 2 Following the forward propagation phase, a loss function is calculated, and this calculated loss function is used for the backpropagation phase to learn and correct the model. Specifically, the backpropagation phase involves: the gradient flow is propagated back to the fusion layer, and the gradient error is compensated to output a corrected gradient. The corrected gradient is then used to update the model parameters. The updated model parameters are used to drive full-precision feature extraction in the forward propagation phase, so that more accurate forward fusion results can be obtained through repeated training, ultimately leading to a high-precision, highly robust quantized model.
[0061] In one embodiment of the present invention, the compensation for gradient error introduced by the pseudo-quantization operation during backpropagation to update the model parameters may specifically include: Step 1060: During the backpropagation of the pseudo-quantization operation, obtain the gradient update amount of the model parameters; Step 1062: Determine the gradient sensitivity based on the magnitude of the change in the gradient update amount; Step 1064: Use the gradient compensation coefficient to compensate for gradient update amounts where the gradient sensitivity is higher than the sensitivity threshold.
[0062] During the backpropagation of the pseudo-quantization operation, when the gradient of the loss function flows through the module corresponding to this operation (hereinafter referred to as the pseudo-quantization node), the system records and captures the original gradient update amount of the target parameter. For example, the target parameter is the weight matrix in the cross-attention layer. Suppose that in a certain training iteration, for a specific weight value w = 0.65 in the cross-attention layer, after forward and backward propagation including the pseudo-quantization node, its original gradient update amount Δθ is calculated. quant =-0.02. This value is captured by the system and used as the basis for subsequent compensation.
[0063] In this embodiment of the invention, the quantization error of the gradient update is the absolute difference between the values of the target parameter before and after the pseudo-quantization operation. That is, the quantization error is: e q = |w - w quant |. Among them, e q Let w be the quantization error, and w be the value of the target parameter before the pseudo-quantization operation. quant The value of the target parameter after pseudo-quantization.
[0064] In one implementation, gradient sensitivity can be defined as the ratio of the quantization error to the normalized absolute value of the target parameter, reflecting the relative perturbation caused by quantization. That is, gradient sensitivity is: S g = e q / (|w| + ε). Where S g ε is the gradient sensitivity, and ε is a minimal constant used to prevent the denominator from being zero.
[0065] Furthermore, a sensitivity threshold can be preset. When the map sensitivity of a certain parameter exceeds the sensitivity threshold, the parameter is considered a high-sensitivity parameter, and its corresponding gradient update amount needs to be compensated.
[0066] One implementation uses gradient compensation coefficients to compensate for gradient updates where the gradient sensitivity exceeds a sensitivity threshold. Specifically, this can include: The correction is performed using the following formula: Δθ compensated = Δθ raw + λ·Δθ quant Where, Δθ compensated The gradient update amount after compensation, Δθ raw The gradient update Δθ is calculated during forward propagation without pseudo-quantization. quant λ is the gradient update calculated during forward propagation after pseudo-quantization, and λ is the learnable gradient compensation coefficient.
[0067] In addition to the correction methods mentioned above, other methods can also be used for correction. For example, an auxiliary gradient estimation network can be used to compensate for gradient updates where the gradient sensitivity is higher than the sensitivity threshold.
[0068] In this embodiment of the invention, the above compensation method can automatically identify the most unstable high-sensitivity parameters due to quantization, and by compensating only these sensitive parameters, the noise amplification problem that may be caused by global compensation can be avoided.
[0069] In one embodiment of the present invention, the model loss can be calculated using at least the following loss function: L QAT = Loss orig + α · Loss quant in, L QAT The loss to be minimized during quantization training. Loss orig The original task loss is calculated based on the training samples and the model's original floating-point output. Loss quant The quantization-perceived loss is calculated based on the training samples and the model's output after pseudo-quantization. α These are the weighting coefficients.
[0070] Furthermore, in addition to the classification result, the output of the malware detection model also includes structured explanatory text and confidence score. In order to ensure the classification accuracy and interpretation consistency of the model during the quantization process, one embodiment of the present invention may further include: monitoring multiple output indicators of the model during the quantization training process; the multiple output indicators include multiple of the following: classification accuracy indicator, explanatory text integrity indicator, and confidence score consistency indicator. The weight coefficients in the loss function are dynamically adjusted based on the feedback results of multiple output metrics.
[0071] Among them, the classification accuracy index is used to measure whether the core detection capability of the model has decreased due to quantization. Specifically, the macro-average F1 score of the model can be calculated as the classification accuracy index.
[0072] The Explanation Text Completeness Index is used to quantify whether the textual explanations provided by the model for decision-making are complete and effective. Specifically, it can be used to evaluate the Explanation Text Completeness Index by comparing the decision reasoning text output by the model's explanation generation module with the standard explanation text generated by a full-precision malware detection model.
[0073] The confidence consistency metric measures whether the sub-decisions made by a model across different modalities are consistent. Specifically, the confidence consistency metric can be evaluated by measuring the divergence of the confidence scores output by the quantization model and the full-precision malware detection model.
[0074] In one implementation, if the model retains both the floating-point precision reference output (FP32 output) and the quantization path output (INT8 output) during quantization training, then an interpretation consistency loss term can be constructed based on both.
[0075] Let the interpretation of the floating-point model be: The interpretation generated by the quantization model is represented as Then explain the consistency loss It can be defined as: Alternatively, when interpreting the output as a probability distribution, the KL divergence form can be used: After calculating the explanation consistency loss, it can be included in the total loss in a weighted manner, that is: L QAT = Loss orig + α · Loss quant + β · Loss explain In this embodiment of the invention, by optimizing multiple output indicators in the quantization process, it can be ensured that the quantized model not only has excellent accuracy, but also maintains high consistency in the generated detection interpretation and confidence, thus meeting the high interpretability requirements.
[0076] Please refer to Figure 3 This invention provides a quantization training device for a multimodal malware detection model, the device comprising: The acquisition unit 300 is used to acquire multiple modal data of the input during the quantization training process of the malware detection model; The determination unit 302 is used to determine the activation quantization scaling factor shared across modalities by utilizing the joint statistical information of the activation values generated by multiple modal data during the forward propagation of the model. The processing unit 304 is used to perform pseudo-quantization processing on the activation value output by each modal branch using the activation quantization scaling factor to generate quantized multimodal features. The compensation unit 306 is used to calculate the model loss based on the multimodal features in forward inference and to compensate for the gradient error introduced by the pseudo-quantization processing operation during the backpropagation process in order to update the model parameters; the acquisition unit, determination unit, processing unit and compensation unit are repeatedly triggered to perform corresponding operations until the model converges and a quantized model is obtained.
[0077] In one embodiment of the present invention, when the determining unit executes the joint statistical information of activation values generated by multiple modal data in the forward propagation of the model to determine the activation quantization scaling factor shared across modalities, the specific steps include: before a preset fusion layer, obtaining the activation value tensor output by each modal branch; calculating the joint numerical distribution of the activation value tensors of multiple modalities; and calculating the activation quantization scaling factor based on the joint numerical distribution.
[0078] In one embodiment of the present invention, when the compensation unit performs the compensation for the gradient error introduced by the pseudo-quantization processing operation during the backpropagation process to update the model parameters, it specifically includes: obtaining the gradient update amount of the model parameters during the backpropagation process of the pseudo-quantization processing operation; determining the gradient sensitivity based on the quantization error of the gradient update amount; and using the gradient compensation coefficient to compensate for the gradient update amount where the gradient sensitivity is higher than the sensitivity threshold.
[0079] In one embodiment of the present invention, when the compensation unit performs the calculation of the model loss, it specifically includes: calculating using the following loss function: L QAT = Loss orig + α × Loss quant in, L QAT The loss to be minimized during quantization training. Loss orig The original task loss is calculated based on the training samples and the model's original floating-point output. Loss quant The quantization-perceived loss is calculated based on the training samples and the model's output after pseudo-quantization. α These are the weighting coefficients.
[0080] In one embodiment of the present invention, it further includes: The monitoring and adjustment unit is used to monitor multiple output metrics of the model during the quantization training process; and dynamically adjust the weight coefficients in the loss function based on the feedback results of multiple output metrics. The multiple output metrics include multiple metrics such as classification accuracy, explanatory text integrity, and confidence consistency.
[0081] In one embodiment of the present invention, the plurality of modal data includes at least: image modal data and text modal data; the image modal data is obtained based on software binary file encoding; the text modal data is generated based on security context information.
[0082] It should be noted that the quantization training device for the multimodal malware detection model provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the quantization training device for the multimodal malware detection model provided in the above embodiments and the quantization training method embodiments for the multimodal malware detection model belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0083] Embodiments of this application also provide a computer device, please refer to... Figure 4 The computer device includes a processor and a memory, the memory storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the quantitative training method for the multimodal malware detection model provided in the above-described method embodiments.
[0084] Embodiments of this application also provide a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the quantitative training method for the multimodal malware detection model provided in the above-described method embodiments.
[0085] Embodiments of this application also provide a computer program product, which includes a computer program. A processor of a computer device reads the computer program from a computer-readable storage medium and executes the computer program, causing the computer device to perform the quantization training method for the multimodal malware detection model described in any of the above embodiments.
[0086] For ease of description, the above systems or devices are described separately as various modules or units based on their functions. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware components.
[0087] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0088] Finally, it should be noted that in this document, relational terms such as first, second, third, and fourth are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0089] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A quantitative training method for a multimodal malware detection model, characterized in that, The method includes: During the quantitative training of the malware detection model, multiple modalities of input data are acquired; By utilizing the joint statistical information of activation values generated by multiple modal data during model forward propagation, the activation quantization scaling factor shared across modalities is determined. The activation value output by each modal branch is pseudo-quantized using the activation quantization scaling factor to generate quantized multimodal features. The model loss is calculated based on the multimodal features in forward inference, and the gradient error introduced by the pseudo-quantization operation is compensated during backpropagation to update the model parameters. Repeat the above steps until the model converges to obtain the quantized model.
2. The method according to claim 1, characterized in that, The method of determining the cross-modal shared activation quantization scaling factor by utilizing the joint statistical information of activation values generated from multiple modal data during model forward propagation includes: Before the preset fusion layer, obtain the activation value tensor of each modal branch output; Calculate the joint numerical distribution of activation value tensors for multiple modes; Based on the joint numerical distribution, the activation quantization scaling factor is calculated.
3. The method according to claim 2, characterized in that, The compensation for gradient errors introduced by the pseudo-quantization operation during backpropagation to update model parameters includes: During the backpropagation of the pseudo-quantization operation, the gradient update amount of the model parameters is obtained; The gradient sensitivity is determined based on the quantization error of the gradient update amount; The gradient compensation coefficient is used to compensate for gradient update amounts when the gradient sensitivity is higher than the sensitivity threshold.
4. The method according to claim 1, characterized in that, The calculation model loss includes: The loss function is used for calculation: L QAT = Loss orig + α × Loss quant in, L QAT The loss to be minimized during quantization training. Loss orig The original task loss is calculated based on the training samples and the model's original floating-point output. Loss quant The quantization-perceived loss is calculated based on the training samples and the model's output after pseudo-quantization. α These are the weighting coefficients.
5. The method according to claim 4, characterized in that, Also includes: During the quantitative training process, monitor multiple output metrics of the model; Multiple output metrics include: classification accuracy metrics, explanatory text completeness metrics, and confidence consistency metrics. The weight coefficients in the loss function are dynamically adjusted based on the feedback results of multiple output metrics.
6. The method according to any one of claims 1-5, characterized in that, The multiple modal data include at least: image modal data and text modal data; the image modal data is obtained based on software binary file encoding; the text modal data is generated based on security context information.
7. A quantitative training device for a multimodal malware detection model, characterized in that, The device includes: The acquisition unit is used to acquire multiple modal data during the quantization training of the malware detection model. The determination unit is used to determine the activation quantization scaling factor shared across modalities by utilizing the joint statistical information of activation values generated by multiple modal data during model forward propagation. The processing unit is used to perform pseudo-quantization processing on the activation value output by each modal branch using the activation quantization scaling factor to generate quantized multimodal features. The compensation unit is used to calculate the model loss based on the multimodal features in forward inference and to compensate for the gradient error introduced by the pseudo-quantization operation during backpropagation in order to update the model parameters; the acquisition unit, determination unit, processing unit and compensation unit are repeatedly triggered to perform corresponding operations until the model converges and the quantized model is obtained.
8. A computer device, characterized in that, The computer device includes a memory and a processor. The memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory to implement the steps of the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the method described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1-6.