File security detection method and device, equipment, storage medium and program product
By using the Conformer model to classify and perform security scans on the files of AI model projects, the lack of security detection in existing technologies is solved. This enables full-file security detection of AI model projects, improving the accuracy and efficiency of detection and providing more comprehensive security protection.
Patent Information
- Application Number
- CN202411028769.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-08
AI Technical Summary
Existing technologies lack security detection capabilities for AI model projects, making it impossible to effectively detect potential security threats and vulnerabilities in AI model projects.
The Conformer model is used to classify the files of AI model projects. The trained Conformer model and AI scanning plugin are used to perform security scanning to identify file types and target type code fields in code files. Feature extraction and classification are performed by combining multi-layer convolutional neural networks and Transformer encoding layers to achieve full file security detection of AI model projects.
It achieves comprehensive security testing of AI model projects, improves the accuracy and efficiency of testing, and can identify malicious code and third-party library information in code files, providing more comprehensive security protection.
Smart Images

Figure CN118916883A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a file security detection method, device, equipment, storage medium and program product. Background Art
[0002] As an advanced neural network model, Conformer can be applied to artificial intelligence (AI) model projects. With the rapid development of artificial intelligence technology, the complexity and scale of AI models continue to increase. AI model projects often involve a large number of resources such as code libraries, third-party dependency libraries, and model files. Therefore, ensuring the security and integrity of these resources is crucial to the smooth progress of the project. Scanning the entire code supply source for AI model projects has become an inevitable choice. This scan not only helps to timely discover potential security threats and vulnerabilities, improve the security and reliability of the project, but also effectively prevents data leaks and security vulnerability incidents, providing strong protection for the development of enterprises and organizations.
[0003] However, existing security detection methods cannot be applied in AI development scenarios. In other words, existing technologies lack security detection functions for AI model projects. Summary of the invention
[0004] The purpose of the present invention is to provide a file security detection method, device, equipment, storage medium and program product to solve the problem of lack of security detection function for AI model projects in the prior art.
[0005] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0006] An embodiment of the present invention provides a file security detection method, comprising:
[0007] Get the files of the first artificial intelligence AI model project;
[0008] Using the trained first Conformer model, classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project;
[0009] According to the first classification result, a corresponding AI scanning plug-in is used to perform a security scan on the files of the first AI model project to obtain a first security detection result of the files of the first AI model project.
[0010] Optionally, the method further comprises:
[0011] According to the first classification result, obtain a first code type file in the files of the first AI model project;
[0012] Using the trained second Conformer model, classify the first code class file to obtain the target type code field in the first code class file;
[0013] Perform security scans on different target type code fields using corresponding AI scanning plug-ins to obtain second security detection results of the target type code fields;
[0014] Based on the first security test result and the second security test result, a final security test result of the first AI model project is obtained.
[0015] Optionally, before classifying files of the first AI model project using the trained first Conformer model to obtain a first classification result of the file type of the first AI model project, the method further includes:
[0016] Using the second classification result of the file of the second AI model project to train the initial Conformer model, to obtain the first Conformer model;
[0017] The initial Conformer model includes a convolution module and a Transformer encoding layer.
[0018] Optionally, the initial Conformer model is trained using the second classification result of the file of the second AI model project to obtain the first Conformer model, including:
[0019] Performing feature extraction on the second classification result to obtain a first data feature of the second classification result;
[0020] Using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer encoding layer to extract features from the first data feature to obtain a second feature;
[0021] Performing pooling classification on the first feature and the second feature respectively to obtain a first training classification result;
[0022] The first Conformer model is obtained according to the first training classification result and the second classification result.
[0023] Optionally, the initial Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a first convolution module and a second convolution module;
[0024] Using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer coding layer to extract features from the first data feature to obtain a second feature, including:
[0025] For a first neural network module, performing a first operation to obtain a third feature and a fourth feature output by the first neural network module, wherein the first neural network module is any one of the at least one neural network module;
[0026] Using the third feature output by the last neural network module as the first feature, and using the fourth feature output by the last neural network module as the second feature;
[0027] The first operation includes:
[0028] Using the first projection convolution layer and the spatial convolution layer in the first convolution module to extract the fifth feature, so as to obtain a sixth feature;
[0029] Performing a first coupling process on the sixth feature to obtain a seventh feature;
[0030] The eighth feature is extracted by using the feedforward neural network, the multi-head attention mechanism and the multi-layer perception mechanism in the Transformer encoding layer to obtain the fourth feature output by the first neural network module; wherein the eighth feature is obtained according to the fifth feature and the seventh feature;
[0031] Performing a second coupling process on the fourth feature to obtain a ninth feature;
[0032] Using the second projected convolution layer in the first convolution module to extract the sixth feature, and adding the fifth feature to obtain a tenth feature;
[0033] Using the first projected convolution layer in the second convolution module to perform convolution processing on the tenth feature to obtain an eleventh feature;
[0034] Performing a third coupling process on the eleventh feature and the ninth feature to obtain a twelfth feature;
[0035] Using the spatial convolution layer and the second projection convolution layer in the second convolution module to extract the twelfth feature, so as to obtain the third feature output by the first neural network module;
[0036] Using the second projected convolution layer in the second convolution module to extract the third feature, and adding the fifth feature to obtain a twelfth feature;
[0037] Wherein, in the case where the first neural network module is the first neural network module, the fifth feature is the first data feature;
[0038] When the first neural network module is not the first neural network module, the fifth feature is the third feature output by the neural network module adjacent to the first neural network module.
[0039] Optionally, obtaining the first Conformer model according to the first training classification result and the second classification result includes:
[0040] Obtaining a first loss error according to the first training classification result and the second classification result;
[0041] When the first loss error is greater than a first preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the first loss error;
[0042] Return to the step of using the convolution module to extract the first data feature to obtain the first feature, and using the Transformer encoding layer to extract the first data feature to obtain the second feature, until the loss error is less than or equal to the first preset error, and obtain the first Conformer model.
[0043] Optionally, before classifying the first code class file using the trained second Conformer model to obtain the target type code field in the first code class file, the method further includes:
[0044] The first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model;
[0045] Among them, the first Conformer model includes a convolution module and a Transformer encoding layer.
[0046] Optionally, the first Conformer model is trained using a second code class file in a file of a second AI model project to obtain the second Conformer model, including:
[0047] Performing feature extraction on the second code class file to obtain a second data feature of the second code class file;
[0048] Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature;
[0049] Performing pooling classification on the thirteenth feature and the fourteenth feature respectively to obtain a second training classification result;
[0050] The second Conformer model is obtained according to the second training classification result and the second code class file.
[0051] Optionally, the first Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a third convolution module and a fourth convolution module;
[0052] Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature, including:
[0053] For a second neural network module, performing a second operation to obtain a fifteenth feature and a sixteenth feature output by the second neural network module, wherein the second neural network module is any one of the at least one neural network module;
[0054] The fifteenth feature output by the last neural network module is used as the thirteenth feature, and the sixteenth feature output by the last neural network module is used as the fourteenth feature;
[0055] The second operation includes:
[0056] Using the first projection convolution layer and the spatial convolution layer in the third convolution module to extract the seventeenth feature, so as to obtain the eighteenth feature;
[0057] Performing a first coupling process on the eighteenth feature to obtain a nineteenth feature;
[0058] The feedforward neural network, multi-head attention mechanism and multi-layer perception mechanism in the Transformer encoding layer are used to extract the twentieth feature to obtain the sixteenth feature output by the second neural network module; wherein the twentieth feature is obtained based on the seventeenth feature and the nineteenth feature;
[0059] Performing a second coupling process on the sixteenth feature to obtain a twenty-first feature;
[0060] Using the second projected convolution layer in the third convolution module to extract the eighteenth feature, and adding the seventeenth feature to obtain the twenty-second feature;
[0061] Using the first projected convolution layer in the fourth convolution module to perform convolution processing on the twenty-second feature to obtain a twenty-third feature;
[0062] Performing a third coupling process on the twenty-third feature and the twenty-first feature to obtain the twenty-fourth feature;
[0063] Performing feature extraction on the twenty-fourth feature using the spatial convolution layer and the second projection convolution layer in the fourth convolution module to obtain the fifteenth feature output by the second neural network module;
[0064] Using the second projected convolution layer in the fourth convolution module to extract the fifteenth feature, and adding the seventeenth feature to obtain a twenty-fourth feature;
[0065] Wherein, in the case where the second neural network module is the first neural network module, the seventeenth feature is the second data feature;
[0066] When the second neural network module is not the first neural network module, the seventeenth feature is the fifteenth feature output by the neural network module adjacent to the second neural network module.
[0067] Optionally, obtaining the second Conformer model according to the second training classification result and the second code class file includes:
[0068] Obtaining a second loss error according to the second training classification result and the second code class file;
[0069] When the second loss error is greater than a second preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the second loss error;
[0070] Return to the step of using the convolution module to extract the second data feature to obtain the thirteenth feature, and using the Transformer encoding layer to extract the second data feature to obtain the fourteenth feature, until the second loss error is less than or equal to the second preset error, and obtain the second Conformer model.
[0071] Optionally, the first coupling process includes:
[0072] Projection convolution processing, average pooling downsampling processing and layer normalization processing.
[0073] Optionally, the second coupling process includes:
[0074] Layer normalization, bicubic interpolation upsampling, and projection convolution.
[0075] The embodiment of the present invention further provides a file security detection device, comprising:
[0076] A first acquisition module, used to acquire a file of a first artificial intelligence AI model project;
[0077] A first processing module, configured to classify files of a first AI model project by using a trained first Conformer model, and obtain a first classification result of the file type of the first AI model project;
[0078] The second processing module is used to perform a security scan on the files of the first AI model project using a corresponding AI scanning plug-in according to the first classification result, so as to obtain a first security detection result of the files of the first AI model project.
[0079] An embodiment of the present invention also provides a file security detection device, comprising: a transceiver, a processor, a memory, and a program or instruction stored in the memory and executable on the processor; when the processor executes the program or instruction, the steps in the file security detection method described in any one of the above are implemented.
[0080] An embodiment of the present invention further provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps in the file security detection method described in any one of the above are implemented.
[0081] An embodiment of the present invention further provides a computer program product, comprising computer instructions, which, when executed by a processor, implement the steps in any one of the file security detection methods described above.
[0082] The beneficial effects of the above technical solution of the present invention are as follows:
[0083] The file security detection method provided by the scheme of the present invention obtains the files of the first AI model project, uses the trained first Conformer model to classify the files of the first AI model project, and obtains a first classification result of the file type of the first AI model project, that is, the classification of each file in the AI model project is realized. According to the first classification result, the corresponding AI scanning plug-in is used to perform a security scan on the files of the first AI model project to obtain a first security detection result of the files of the first AI model project, that is, the security detection function of the AI model project is realized, which has better scenario applicability in the field of AI security. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] Figure 1 A flowchart of a file security detection method provided by an embodiment of the present invention;
[0085] Figure 2 A training flow chart of a Conformer network provided in an embodiment of the present invention;
[0086] Figure 3 The overall flow chart of the one-stage and two-stage training Conformer model provided by the embodiment of the present invention;
[0087] Figure 4 An overall flow chart of the file security detection method provided by an embodiment of the present invention;
[0088] Figure 5 A schematic diagram of the structure of a file security detection device provided by an embodiment of the present invention;
[0089] Figure 6 A schematic diagram of the structure of a file security detection device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0090] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0091] In order to solve the problem of lack of security detection function for AI model projects in the prior art, the embodiments of the present invention provide a file security detection method, device, equipment, storage medium and program product.
[0092] like Figure 1 As shown, an embodiment of the present invention provides a file security detection method, comprising:
[0093] Step 101: Obtain files of a first artificial intelligence AI model project.
[0094] Among them, the first AI model project is an AI model project to be classified.
[0095] Step 102: Use the trained first Conformer model to classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project.
[0096] It should be noted that the Conformer model is a language model invented by OpenAI, which uses the Attention mechanism to build a new deep neural network architecture that can better capture long-term dependencies in text. It uses a hybrid architecture with higher computational efficiency and lower model size. It will improve machine reading comprehension and language generation tasks through better computing performance, more powerful language modeling capabilities, and tighter semantic representation.
[0097] Conformer is a sequence-to-sequence model based on the self-attention mechanism. It is an improvement on the Transformer model, mainly to solve the efficiency and performance problems when long sequences are input. The Conformer model uses multi-layer superimposed deep convolutional neural networks (CNN) and self-attention mechanisms, as well as position encoding, residual connections, and layer normalization.
[0098] In this step, the trained first Conformer model is used to classify the files of the first AI model project to obtain a first classification result of the file type of the first AI model project, wherein the first classification result includes at least one of the following: code remote control files, dependency framework environment files, code-like text files (or called code-like files), and model files generated by the AI model project.
[0099] Through this step, the trained first Conformer model is used to classify the AI model project files to be classified, and the first-stage file type classification results (i.e., the first classification results) are obtained. For example, the output is the model files generated by the AI model project such as .h5 and .pth, and code texts such as ipynb.
[0100] Step 103: Based on the first classification result, a corresponding AI scanning plug-in is used to perform a security scan on the files of the first AI model project to obtain a first security detection result of the files of the first AI model project.
[0101] In this step, the classified files are scanned using the corresponding AI security scanning plug-in to obtain the scanning plug-in security source scanning results (i.e., the first security detection results) corresponding to each file of the AI model project to be detected classified in the first stage.
[0102] Specifically, for model files generated by AI model projects such as .h5 and .pth, model scanning plug-ins such as modelscan are called to generate model security source and model structure scans, and Nbdefense plug-ins are used to scan malicious sources for code files such as ipynb. After all classified files are scanned by the corresponding AI security scanning plug-in, the results of the security source scanning of each file of the AI model to be tested classified in the first stage are obtained.
[0103] Furthermore, the method further comprises:
[0104] Perform two-stage training on the first Conformer model to obtain a trained second Conformer model;
[0105] According to the first classification result, a first code class file in the files of the first AI model project is obtained, that is, a code class file (that is, a first code class file) in the AI model project to be detected classified in the first stage is obtained;
[0106] Using the trained second Conformer model, classify the first code class file to obtain the target type code field in the first code class file;
[0107] The target type code field includes at least one of the following:
[0108] Third-party source library fields, import framework fields, and malicious code fields.
[0109] That is, the code class files classified in the first stage in the AI model project file to be detected are input into the Conformer model trained in the second stage (i.e., the second Conformer model) for identification and classification, and all the third-party source libraries, import frameworks, malicious code information and other fields referenced in the code class files in the AI model project to be detected are obtained.
[0110] The corresponding AI scanning plug-in is used to perform security scans on different target type code fields to obtain a second security detection result of the target type code field.
[0111] The fields such as third-party source libraries, imported frameworks, and malicious codes referenced in the code class files of the AI model project to be tested classified by the Conformer model trained in the second stage are scanned using the corresponding AI scanning plug-in for security traceability information such as third-party source libraries, imported frameworks, and malicious codes, as well as supply source code package vulnerabilities to obtain the security scanning results after the second stage classification (i.e., the second security detection results).
[0112] Based on the first security detection mechanism and the second security detection result, the final security detection result of the first AI model project is obtained, that is, the security scanning result of the model file scanned in the first stage (i.e., the first security scanning result) and the second security detection result of the second stage are summarized and integrated, and the security source detection scanning result of the entire file of the AI model project to be detected (i.e., the final security detection result) is output.
[0113] The following describes the training process of the Conformer network:
[0114] In an optional embodiment, before classifying files of the first AI model project using the trained first Conformer model and obtaining a first classification result of the file type of the first AI model project, the method further includes:
[0115] Using the second classification result of the file of the second AI model project to train the initial Conformer model, to obtain the first Conformer model;
[0116] The initial Conformer model includes a convolution module and a Transformer encoding layer.
[0117] It should be noted that there are multiple second AI model projects, and the second classification results include the code remote control files required by multiple second AI model projects, the dependent framework environment files, all code class files, the full file suffix of the model files generated by the model projects, and the file type information.
[0118] The second classification result is used as training data.
[0119] In this embodiment, the second classification result and the AI scanning plug-in corresponding to each file in the above classification result are input as labels into the initial Conformer model for training to obtain the first Conformer model.
[0120] The trained first Conformer model is then used to classify the entire file of the AI model project to be tested.
[0121] It should also be noted that the initial Conformer model in this embodiment includes a convolution module and a Transformer encoding layer.
[0122] The training process of the Conformer network is as follows Figure 2 shown.
[0123] Furthermore, the initial Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer coding layer, and the convolution module group includes a first convolution module and a second convolution module. It can be understood that the initial Conformer model includes N dual-parallel branch network modules (i.e., neural network modules), each of which includes 2 convolution modules (or convolution blocks) and 1 Transformer coding layer (or Transformer coding block). The initial Conformer model can also be called an improved Conformer model.
[0124] Among them, the Transformer encoding layer mainly includes two main sub-layers: the Self-Attention sub-layer and the Feed Forward Neural Network (FFN) sub-layer.
[0125] Further, the initial Conformer model is trained using the second classification result of the file of the second AI model project to obtain the first Conformer model, including:
[0126] Feature extraction is performed on the second classification result to obtain the first data feature of the second classification result. Specifically, after the initial Conformer model receives the training data (the second classification result), the second classification result is first placed in the initial feature extraction layer (or called the initial feature extraction module, the initial feature extraction block) for feature extraction. The initial feature extraction layer uses a 7×7 convolution kernel with a step size of 2 to perform global first data feature extraction on the training data of the file type information, and then uses a 3×3 maximum pooling kernel with a step size of 2 to extract edge and texture features to obtain the first data feature X1 of all file information.
[0127] The first data feature is extracted by using the convolution module to obtain the first feature, and the first data feature is extracted by using the Transformer coding layer to obtain the second feature. That is, after the first data feature is input into the neural network module, the first data feature is extracted by using the parallel convolution module group and the Transformer coding layer in the neural network module to obtain the first feature output by the convolution module. and the second feature output of the Transformer encoding layer
[0128] The first feature and the second feature are pooled and classified respectively to obtain a first training classification result, that is, the first feature output by the convolution module and the features output by the Transformer encoding layer Perform pooling classification (classifier) to obtain the first training classification result.
[0129] The first Conformer model is obtained according to the first training classification result and the second classification result.
[0130] Furthermore, using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer encoding layer to extract features from the first data feature to obtain a second feature, including:
[0131] For a first neural network module, performing a first operation to obtain a third feature and a fourth feature output by the first neural network module, wherein the first neural network module is any one of the at least one neural network module;
[0132] Using the third feature output by the last neural network module as the first feature, and using the fourth feature output by the last neural network module as the second feature;
[0133] The first operation includes:
[0134] Using the first projection convolution layer and the spatial convolution layer in the first convolution module to extract the fifth feature, so as to obtain a sixth feature;
[0135] Performing a first coupling process on the sixth feature to obtain a seventh feature; wherein the first coupling process includes: projection convolution processing, average pooling downsampling processing, and layer normalization processing;
[0136] The eighth feature is extracted by using the feedforward neural network, the multi-head attention mechanism and the multi-layer perception mechanism in the Transformer encoding layer to obtain the fourth feature output by the first neural network module; wherein the eighth feature is obtained according to the fifth feature and the seventh feature;
[0137] Performing a second coupling process on the fourth feature to obtain a ninth feature; wherein the second coupling process includes: layer normalization processing, bicubic interpolation upsampling processing and projection convolution processing;
[0138] Using the second projected convolution layer in the first convolution module to extract the sixth feature, and adding the fifth feature to obtain a tenth feature;
[0139] Using the first projected convolution layer in the second convolution module to perform convolution processing on the tenth feature to obtain an eleventh feature;
[0140] Performing a third coupling process on the eleventh feature and the ninth feature to obtain a twelfth feature;
[0141] Using the spatial convolution layer and the second projection convolution layer in the second convolution module to extract the twelfth feature, so as to obtain the third feature output by the first neural network module;
[0142] Using the second projected convolution layer in the second convolution module to extract the third feature, and adding the fifth feature to obtain a twelfth feature;
[0143] Wherein, in the case where the first neural network module is the first neural network module, the fifth feature is the first data feature;
[0144] When the first neural network module is not the first neural network module, the fifth feature is the third feature output by the neural network module adjacent to the first neural network module.
[0145] Specifically, the process of processing the first data feature using the neural network module is as follows:
[0146] After the first data feature X1 (i.e., the fifth feature) enters the first neural network module, X1 enters the left branch convolution layer (convolution module group). In the first convolution module, it first passes through the 1×1 down-projection convolution layer (i.e., the first projection convolution layer) and the 3×3 spatial convolution layer for convolution feature extraction to obtain the sixth feature.
[0147] The sixth feature is ready to be coupled to the Transformer encoding layer of the first neural network module, and the sixth feature is also transmitted downward in the convolution module group, and horizontally transmitted to the feature coupling layer (or called feature coupling unit). The sixth feature transmitted in the feature coupling layer is first coupled and processed to obtain the seventh feature. Specifically, the sixth feature The transfer first passes through a layer of 1×1 down-projection convolution (1×1Conv) to normalize the features Then the adaptive global average pooling downsampling (spatial pyramid pooling sampling) of the improved application is used and normalized to the same scale features of the Transformer encoding layer (The seventh characteristic): Among them, the calculation of adaptive global average pooling downsampling is:
[0148]
[0149] Among them, x represents The feature vector at the jth position in the feature.
[0150] In the Transformer coding layer of the right branch, the eighth feature is obtained according to the fifth feature (i.e., the first data feature X1) and the seventh feature. Specifically, the first data feature X1 is first processed into the receiving data X1 of the Transformer coding layer by feature embedding. t , will receive data X t and the seventh characteristic Perform feature coupling processing to obtain the coding layer coupling feature data, i.e. the eighth feature
[0151] After the eighth feature enters the Transformer encoding layer, it is normalized by the feedforward neural network layer and extracted by the multi-head attention mechanism: After that, we enter the layer normalization process and the MLP multi-layer perceptron block (i.e., multi-layer perceptron mechanism) to learn the feature representation and obtain the fourth feature
[0152] The fourth feature is not only outputted downward as the output of the Transformer encoding layer, but also enters the feature coupling layer (feature coupling unit) horizontally for the second coupling process to obtain the ninth feature. Specifically, after layer normalization, improved bicubic interpolation upsampling and projection convolution (1×1Conv), the ninth feature is obtained. Among them, the calculation operation of bicubic interpolation upsampling is:
[0153]
[0154] Among them, x i is the feature vector in the encoding layer at position i, and B is the bicubic interpolation parameter used to adjust the smooth expansion rate.
[0155] Pass the sixth feature down in the convolution module Enter the last 1×1 up-projection convolution of the first convolution module (the second projection convolution layer in the first convolution module) to recover the features, and add the fifth feature X1 to obtain the tenth feature
[0156] Then, the tenth feature Entering the second convolution module, after the same layer of 1×1 down-projection convolution (the first projection convolution layer), the eleventh feature is obtained. The eleventh characteristic The encoding layer features passed from the Transformer encoding layer through the feature coupling layer (i.e., the ninth feature) is coupled to obtain the twelfth feature
[0157] The twelfth characteristic Then, the output features of the last two convolution modules are obtained by performing convolution feature learning and extraction through the last 3×3 spatial convolution layer and 1×1 down-projection convolution layer (second projection convolution layer) of the second convolution module. That is the third characteristic.
[0158] Further, according to the first training classification result and the second classification result, the first Conformer model is obtained, including:
[0159] Obtaining a first loss error according to the first training classification result and the second classification result;
[0160] When the first loss error is greater than the first preset error, the model parameters of the convolution module and the model parameters of the Transformer coding layer are adjusted according to the first loss error, that is, the error is passed back to the convolution module and the Transformer coding layer in the initial Conformer model for parameter optimization.
[0161] Return to the step of using the convolution module to extract the first data feature to obtain the first feature, and using the Transformer encoding layer to extract the first data feature to obtain the second feature, until the loss error is less than or equal to the first preset error (that is, until the loss value converges), and obtain the first Conformer model.
[0162] Use the first Conformer model to classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project.
[0163] Please refer to the training process of the first Conformer model Figure 2 .
[0164] In an optional embodiment, the first code class file is classified using the trained second Conformer model to obtain the target type code field in the first code class file, and the first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model;
[0165] The first Conformer model includes a convolution module (or called a convolution block) and a Transformer coding layer (or called a Transformer coding block).
[0166] It should be noted that the second code type file is the first classification result of the second AI model project obtained by the first Conformer model after the file of the second AI model project is output to the first Conformer model. The code type file in the file of the second AI model project obtained according to the first classification result is the second code type file.
[0167] Specifically, the third-party library source field, reference framework field, and malicious code field in the second code class file are input as labels into the first Conformer model for a new two-stage training to obtain a second Conformer model.
[0168] Further, the first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model, including:
[0169] Performing feature extraction on the second code class file to obtain a second data feature of the second code class file;
[0170] Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature;
[0171] Performing pooling classification on the thirteenth feature and the fourteenth feature respectively to obtain a second training classification result;
[0172] The second Conformer model is obtained according to the second training classification result and the second code class file.
[0173] Furthermore, the first Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a third convolution module and a fourth convolution module;
[0174] Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature, including:
[0175] For a second neural network module, performing a second operation to obtain a fifteenth feature and a sixteenth feature output by the second neural network module, wherein the second neural network module is any one of the at least one neural network module;
[0176] The fifteenth feature output by the last neural network module is used as the thirteenth feature, and the sixteenth feature output by the last neural network module is used as the fourteenth feature;
[0177] The second operation includes:
[0178] Using the first projection convolution layer and the spatial convolution layer in the third convolution module to extract the seventeenth feature, so as to obtain the eighteenth feature;
[0179] Performing a first coupling process on the eighteenth feature to obtain a nineteenth feature;
[0180] The feedforward neural network, multi-head attention mechanism and multi-layer perception mechanism in the Transformer encoding layer are used to extract the twentieth feature to obtain the sixteenth feature output by the second neural network module; wherein the twentieth feature is obtained based on the seventeenth feature and the nineteenth feature;
[0181] Performing a second coupling process on the sixteenth feature to obtain a twenty-first feature;
[0182] Using the second projected convolution layer in the third convolution module to extract the eighteenth feature, and adding the seventeenth feature to obtain the twenty-second feature;
[0183] Using the first projected convolution layer in the fourth convolution module to perform convolution processing on the twenty-second feature to obtain a twenty-third feature;
[0184] Performing a third coupling process on the twenty-third feature and the twenty-first feature to obtain the twenty-fourth feature;
[0185] Performing feature extraction on the twenty-fourth feature using the spatial convolution layer and the second projection convolution layer in the fourth convolution module to obtain the fifteenth feature output by the second neural network module;
[0186] Using the second projected convolution layer in the fourth convolution module to extract the fifteenth feature, and adding the seventeenth feature to obtain a twenty-fourth feature;
[0187] Wherein, in the case where the second neural network module is the first neural network module, the seventeenth feature is the second data feature;
[0188] When the second neural network module is not the first neural network module, the seventeenth feature is the fifteenth feature output by the neural network module adjacent to the second neural network module.
[0189] Wherein, the first coupling process includes:
[0190] Projection convolution processing, average pooling downsampling processing and layer normalization processing.
[0191] The second coupling process comprises:
[0192] Layer normalization, bicubic interpolation upsampling, and projection convolution.
[0193] Furthermore, according to the second training classification result and the second code class file, the second Conformer model is obtained, including:
[0194] Obtaining a second loss error according to the second training classification result and the second code class file;
[0195] When the second loss error is greater than a second preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the second loss error;
[0196] Return to the step of using the convolution module to extract the second data feature to obtain the thirteenth feature, and using the Transformer encoding layer to extract the second data feature to obtain the fourteenth feature, until the second loss error is less than or equal to the second preset error, and obtain the second Conformer model.
[0197] It should also be noted that the training work and process of the first Conformer model are the same as those of the initial Conformer model, and will not be repeated here. The dual-branch convolutional layer and Transformer encoding layer not only perform their own feature learning, but also fuse their own features through the feature coupling network to improve the feature learning accuracy and enrich the feature information. When the loss value converges and the test set classification accuracy is accurate and stable, the two-stage trained Conformer model is obtained, that is, the second Conformer model.
[0198] Then, the code files classified in the first stage in the project file of the AI model to be tested are input into the Conformer model trained in the second stage for identification and classification, and all the third-party source libraries, import frameworks and malicious code information referenced in the code file of the project to be tested, that is, the target type code field, are obtained.
[0199] Combine the following Figure 3 The overall process of the one-stage and two-stage training Conformer model provided by the embodiment of the present invention is specifically described as follows:
[0200] Input the full file type information (second classification result) of all the second AI model projects in the training set as training data, and the corresponding AI scanning plug-in name is label; input the training data and labels into the initial Conformer model for training to obtain a one-stage training model, i.e., the first Conformer model; use the one-stage training model to classify the code class files of the second AI model project, i.e., the second code class files, and use the second code class files as training data, malicious code fields and third-party library fields as labels, input the training data and labels into the first Conformer model for training to obtain the second Conformer model; use the second Conformer model to classify the first code class files to obtain the target type code fields in the first code class files.
[0201] Combine the following Figure 4 , specifically describes the overall process of the file security detection method provided by the embodiment of the present invention:
[0202] The code remote control files, dependent framework environments, all code texts, and full file suffixes and file type information of the generated model files required by multiple second artificial intelligence model projects are used as training data and the security model scanning plug-in names corresponding to the above file types are used as labels to input into the initial Conformer model for training, and the trained network model (first Conformer model) is obtained. The classification model (first Conformer model) is then used to classify all files of the first AI model project to be tested. According to the results of the classified file types, the model scanning plug-in corresponding to each category of files is used to perform security source scanning, and then the depth of the first-stage training set is divided into The learning code text data is used as the second-stage training set, in which the malicious code field, the introduced third-party library field and the application framework field are used as the second-stage training labels and input into the improved Conformer for the second-stage training. After the second-stage training model is obtained, the code text file in the first AI model project to be tested classified in the first stage is input into the second-stage model to identify and detect malicious code, third-party imported deep learning libraries and application frameworks, and use the corresponding AI framework scanning, AI third-party library detection and other model scanning plug-ins to perform security scans on the identified third-party library sources and introduced frameworks, and summarize and integrate the two scanning results as the complete AI model full project file supply source security detection results.
[0203] The embodiment of the present invention uses an improved Conformer model. The model structure of the Transformer encoding layer and the convolutional network in parallel applied in the model can not only capture multi-scale detail feature information through convolution operations during classification, but also the self-attention mechanism and multi-head attention mechanism of the encoding layer are more conducive to the extraction of key information of global features and attention to local features, which comprehensively improves the accuracy of the model in AI model file classification; more importantly, the method optimizes and improves the feature coupling layer of the Conformer parallel network, optimizes and introduces adaptive global average pooling downsampling and bicubic interpolation upsampling technology, so that the convolution layer and the Transformer encoding layer share parameters. It can not only adaptively and dynamically adjust the size of the pooling kernel and better retain effective feature position information during pooling, but also more effectively extract data detail information through cubic interpolation function when feature data is amplified. The application of two improved sampling technologies improves the effective representation of shared feature parameters of coupling units and improves the classification accuracy and stability of the model. Subsequently, the improved Conformer network is used to perform secondary fine recognition of the code text classes detected by the first classification, and classify malicious code, third-party import library sources, and application framework information. Compared with one-step detection, it can more finely classify AI model full project files that can be scanned by security supply source plug-ins, including deep learning code introduced by third-party packages.
[0204] In addition, after realizing the fine classification of various file types in the entire AI model project through the two-stage call of the improved Conformer model, the application of various types of AI scanning plug-ins can not only complete the security scanning of the generated network model and deep learning code malicious detection in the entire AI project, but also supplement the realization of the AI model project's code control files, third-party dependency library information, the introduction of deep learning frameworks and other file information security source scanning, integrating and improving the AI model project's full file information security supply source detection scanning results. The supply source security scanning method of calling the AI model scanning plug-in multiple times and separately not only improves the efficiency of security detection, but also improves the detailed supply source security detection of each file information contained in the entire project, providing comprehensive protection for the security of AI projects, and has better engineering feasibility and scenario applicability in the field of AI project security.
[0205] The Conformer model in the embodiment of the present invention has better local feature extraction capability and global feature integration than the graph convolutional neural network model used, and improves the classification accuracy and processing efficiency. Compared with the traditional transformer model used, it not only adds more convolution feature extraction in different domains of different scales, thereby having better multi-file classification accuracy, but also the spatial invariance of its convolution operation makes the model more stable during file classification detection. The feature coupling unit of the Conformer is optimized, and adaptive global average pooling downsampling and bicubic interpolation upsampling are used. When the network parameters are shared, compared with the original simple extraction downsampling method of the Conformer, the adaptive operation can automatically adjust the size of the pooling kernel during average pooling according to the size characteristics of the input and output data, and better retain the effective feature position information. Compared with the linear interpolation method of the original Conformer, the bicubic interpolation can more effectively extract the feature detail information of the data during the upsampling operation. The application of the two improved sampling technologies improves the effective representation of the shared feature parameters of the coupling unit, so that the two branch layers of the Conformer can learn the feature information more accurately and in detail, further improving the training efficiency and classification accuracy of the model. By applying the improved Conformer model, we realize the automatic classification of file types corresponding to each model scanning plug-in under the entire AI model project. At the same time, we apply the improved Conformer model to the classified code text to perform fine identification of code content imported into the AI third-party library and introduced framework. Subsequently, we perform security scanning on the AI model security scanning plug-ins corresponding to all classified AI full model files, frameworks, etc., and integrate all scanning results, which meets the detailed supply source security detection of AI full project information, has higher AI project security model supply source detection efficiency and more complete security model detection function, and has better scenario applicability in the field of AI security.
[0206] like Figure 5 As shown, an embodiment of the present invention further provides a file security detection device, comprising:
[0207] A first acquisition module 501 is used to acquire a file of a first artificial intelligence AI model project;
[0208] A first processing module 502 is used to classify files of a first AI model project using a trained first Conformer model to obtain a first classification result of the file type of the first AI model project;
[0209] The second processing module 503 is used to perform a security scan on the files of the first AI model project using a corresponding AI scanning plug-in according to the first classification result, so as to obtain a first security detection result of the files of the first AI model project.
[0210] Furthermore, the device also includes:
[0211] A second acquisition module, used to acquire a first code type file from the files of the first AI model project according to the first classification result;
[0212] A third processing module is used to classify the first code class file by using the trained second Conformer model to obtain a target type code field in the first code class file;
[0213] A fourth processing module, configured to perform security scanning on different target type code fields using a corresponding AI scanning plug-in to obtain a second security detection result of the target type code field;
[0214] The fifth processing module is used to obtain the final security detection result of the first AI model project based on the first security detection result and the second security detection result.
[0215] Optionally, the device further comprises:
[0216] A sixth processing module, configured to train an initial Conformer model using a second classification result of the file of the second AI model project to obtain the first Conformer model;
[0217] The initial Conformer model includes a convolution module and a Transformer encoding layer.
[0218] Optionally, the sixth processing module includes:
[0219] A first processing unit, configured to perform feature extraction on the second classification result to obtain a first data feature of the second classification result;
[0220] A second processing unit is used to extract features from the first data feature using the convolution module to obtain a first feature, and to extract features from the first data feature using the Transformer encoding layer to obtain a second feature;
[0221] A third processing unit, used to perform pooling classification on the first feature and the second feature respectively to obtain a first training classification result;
[0222] The fourth processing unit is used to obtain the first Conformer model according to the first training classification result and the second classification result.
[0223] Optionally, the initial Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a first convolution module and a second convolution module;
[0224] The second processing unit is specifically configured to:
[0225] For a first neural network module, performing a first operation to obtain a third feature and a fourth feature output by the first neural network module, wherein the first neural network module is any one of the at least one neural network module;
[0226] Using the third feature output by the last neural network module as the first feature, and using the fourth feature output by the last neural network module as the second feature;
[0227] The first operation includes:
[0228] Using the first projection convolution layer and the spatial convolution layer in the first convolution module to extract the fifth feature, so as to obtain a sixth feature;
[0229] Performing a first coupling process on the sixth feature to obtain a seventh feature;
[0230] The eighth feature is extracted by using the feedforward neural network, the multi-head attention mechanism and the multi-layer perception mechanism in the Transformer encoding layer to obtain the fourth feature output by the first neural network module; wherein the eighth feature is obtained according to the fifth feature and the seventh feature;
[0231] Performing a second coupling process on the fourth feature to obtain a ninth feature;
[0232] Using the second projected convolution layer in the first convolution module to extract the sixth feature, and adding the fifth feature to obtain a tenth feature;
[0233] Using the first projected convolution layer in the second convolution module to perform convolution processing on the tenth feature to obtain an eleventh feature;
[0234] Performing a third coupling process on the eleventh feature and the ninth feature to obtain a twelfth feature;
[0235] Using the spatial convolution layer and the second projection convolution layer in the second convolution module to extract the twelfth feature, so as to obtain the third feature output by the first neural network module;
[0236] Using the second projected convolution layer in the second convolution module to extract the third feature, and adding the fifth feature to obtain a twelfth feature;
[0237] Wherein, in the case where the first neural network module is the first neural network module, the fifth feature is the first data feature;
[0238] When the first neural network module is not the first neural network module, the fifth feature is the third feature output by the neural network module adjacent to the first neural network module.
[0239] Optionally, the fourth processing unit is specifically configured to:
[0240] Obtaining a first loss error according to the first training classification result and the second classification result;
[0241] When the first loss error is greater than a first preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the first loss error;
[0242] Return to the step of using the convolution module to extract the first data feature to obtain the first feature, and using the Transformer encoding layer to extract the first data feature to obtain the second feature, until the loss error is less than or equal to the first preset error, and obtain the first Conformer model.
[0243] Optionally, the device further comprises:
[0244] A seventh processing module, configured to train the first Conformer model using a second code class file in the file of the second AI model project to obtain the second Conformer model;
[0245] Among them, the first Conformer model includes a convolution module and a Transformer encoding layer.
[0246] Optionally, the seventh processing module includes:
[0247] a fifth processing unit, configured to extract features from the second code class file to obtain a second data feature of the second code class file;
[0248] a sixth processing unit, configured to perform feature extraction on the second data feature using the convolution module to obtain a thirteenth feature, and to perform feature extraction on the second data feature using the Transformer encoding layer to obtain a fourteenth feature;
[0249] a seventh processing unit, configured to perform pooling classification on the thirteenth feature and the fourteenth feature respectively to obtain a second training classification result;
[0250] An eighth processing unit is used to obtain the second Conformer model according to the second training classification result and the second code class file.
[0251] Optionally, the first Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a third convolution module and a fourth convolution module;
[0252] The sixth processing unit is specifically configured to:
[0253] For a second neural network module, performing a second operation to obtain a fifteenth feature and a sixteenth feature output by the second neural network module, wherein the second neural network module is any one of the at least one neural network module;
[0254] The fifteenth feature output by the last neural network module is used as the thirteenth feature, and the sixteenth feature output by the last neural network module is used as the fourteenth feature;
[0255] The second operation includes:
[0256] Using the first projection convolution layer and the spatial convolution layer in the third convolution module to extract the seventeenth feature, so as to obtain the eighteenth feature;
[0257] Performing a first coupling process on the eighteenth feature to obtain a nineteenth feature;
[0258] The feedforward neural network, multi-head attention mechanism and multi-layer perception mechanism in the Transformer encoding layer are used to extract the twentieth feature to obtain the sixteenth feature output by the second neural network module; wherein the twentieth feature is obtained based on the seventeenth feature and the nineteenth feature;
[0259] Performing a second coupling process on the sixteenth feature to obtain a twenty-first feature;
[0260] Using the second projected convolution layer in the third convolution module to extract the eighteenth feature, and adding the seventeenth feature to obtain the twenty-second feature;
[0261] Using the first projected convolution layer in the fourth convolution module to perform convolution processing on the twenty-second feature to obtain a twenty-third feature;
[0262] Performing a third coupling process on the twenty-third feature and the twenty-first feature to obtain the twenty-fourth feature;
[0263] Performing feature extraction on the twenty-fourth feature using the spatial convolution layer and the second projection convolution layer in the fourth convolution module to obtain the fifteenth feature output by the second neural network module;
[0264] Using the second projected convolution layer in the fourth convolution module to extract the fifteenth feature, and adding the seventeenth feature to obtain a twenty-fourth feature;
[0265] Wherein, in the case where the second neural network module is the first neural network module, the seventeenth feature is the second data feature;
[0266] When the second neural network module is not the first neural network module, the seventeenth feature is the fifteenth feature output by the neural network module adjacent to the second neural network module.
[0267] Optionally, the eighth processing unit is specifically configured to:
[0268] Obtaining a second loss error according to the second training classification result and the second code class file;
[0269] When the second loss error is greater than a second preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the second loss error;
[0270] Return to the step of using the convolution module to extract the second data feature to obtain the thirteenth feature, and using the Transformer encoding layer to extract the second data feature to obtain the fourteenth feature, until the second loss error is less than or equal to the second preset error, and obtain the second Conformer model.
[0271] Optionally, the first coupling process includes:
[0272] Projection convolution processing, average pooling downsampling processing and layer normalization processing.
[0273] Optionally, the second coupling process includes:
[0274] Layer normalization, bicubic interpolation upsampling, and projection convolution.
[0275] It should be noted that the file security detection device provided in the embodiment of the present invention is a device capable of executing the above-mentioned file security detection method, and all embodiments of the above-mentioned file security detection method are applicable to the device and can achieve the same or similar technical effects.
[0276] like Figure 6 As shown, an embodiment of the present invention also provides a file security detection device, including: a processor 601; and a memory 603 connected to the processor 601 through a bus interface 602, the memory 603 is used to store programs and data used by the processor 601 when performing operations, and the processor 601 calls and executes the programs and data stored in the memory 603.
[0277] The transceiver 604 is connected to the bus interface 602 and is used to receive and send data under the control of the processor 601. Specifically, the processor 601 is used to read the program in the memory 603 and execute the following process:
[0278] Get the files of the first artificial intelligence AI model project;
[0279] Using the trained first Conformer model, classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project;
[0280] According to the first classification result, a corresponding AI scanning plug-in is used to perform a security scan on the files of the first AI model project to obtain a first security detection result of the files of the first AI model project.
[0281] Optionally, the processor 601 is further configured to:
[0282] According to the first classification result, obtain a first code type file in the files of the first AI model project;
[0283] Using the trained second Conformer model, classify the first code class file to obtain the target type code field in the first code class file;
[0284] Perform security scans on different target type code fields using corresponding AI scanning plug-ins to obtain second security detection results of the target type code fields;
[0285] Based on the first security test result and the second security test result, a final security test result of the first AI model project is obtained.
[0286] Optionally, the processor 601 is further configured to:
[0287] Before using the trained first Conformer model to classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project, the initial Conformer model is trained using a second classification result of files of the second AI model project to obtain the first Conformer model;
[0288] The initial Conformer model includes a convolution module and a Transformer encoding layer.
[0289] Optionally, the processor 601 is specifically configured to:
[0290] Performing feature extraction on the second classification result to obtain a first data feature of the second classification result;
[0291] Using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer encoding layer to extract features from the first data feature to obtain a second feature;
[0292] Performing pooling classification on the first feature and the second feature respectively to obtain a first training classification result;
[0293] The first Conformer model is obtained according to the first training classification result and the second classification result.
[0294] Optionally, the initial Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a first convolution module and a second convolution module;
[0295] The processor 601 is specifically configured to:
[0296] For a first neural network module, performing a first operation to obtain a third feature and a fourth feature output by the first neural network module, wherein the first neural network module is any one of the at least one neural network module;
[0297] Using the third feature output by the last neural network module as the first feature, and using the fourth feature output by the last neural network module as the second feature;
[0298] The first operation includes:
[0299] Using the first projection convolution layer and the spatial convolution layer in the first convolution module to extract the fifth feature, so as to obtain a sixth feature;
[0300] Performing a first coupling process on the sixth feature to obtain a seventh feature;
[0301] The eighth feature is extracted by using the feedforward neural network, the multi-head attention mechanism and the multi-layer perception mechanism in the Transformer encoding layer to obtain the fourth feature output by the first neural network module; wherein the eighth feature is obtained according to the fifth feature and the seventh feature;
[0302] Performing a second coupling process on the fourth feature to obtain a ninth feature;
[0303] Using the second projected convolution layer in the first convolution module to extract the sixth feature, and adding the fifth feature to obtain a tenth feature;
[0304] Using the first projected convolution layer in the second convolution module to perform convolution processing on the tenth feature to obtain an eleventh feature;
[0305] Performing a third coupling process on the eleventh feature and the ninth feature to obtain a twelfth feature;
[0306] Using the spatial convolution layer and the second projection convolution layer in the second convolution module to extract the twelfth feature, so as to obtain the third feature output by the first neural network module;
[0307] Using the second projected convolution layer in the second convolution module to extract the third feature, and adding the fifth feature to obtain a twelfth feature;
[0308] Wherein, in the case where the first neural network module is the first neural network module, the fifth feature is the first data feature;
[0309] When the first neural network module is not the first neural network module, the fifth feature is the third feature output by the neural network module adjacent to the first neural network module.
[0310] Optionally, the processor 601 is specifically configured to:
[0311] Obtaining a first loss error according to the first training classification result and the second classification result;
[0312] When the first loss error is greater than a first preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the first loss error;
[0313] Return to the step of using the convolution module to extract the first data feature to obtain the first feature, and using the Transformer encoding layer to extract the first data feature to obtain the second feature, until the loss error is less than or equal to the first preset error, and obtain the first Conformer model.
[0314] Optionally, the processor 601 is further configured to:
[0315] Before using the trained second Conformer model to classify the first code class file to obtain the target type code field in the first code class file, the first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model;
[0316] Among them, the first Conformer model includes a convolution module and a Transformer encoding layer.
[0317] Optionally, the processor 601 is specifically configured to:
[0318] Performing feature extraction on the second code class file to obtain a second data feature of the second code class file;
[0319] Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature;
[0320] Performing pooling classification on the thirteenth feature and the fourteenth feature respectively to obtain a second training classification result;
[0321] The second Conformer model is obtained according to the second training classification result and the second code class file.
[0322] Optionally, the first Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a third convolution module and a fourth convolution module;
[0323] The processor 601 is specifically configured to:
[0324] For a second neural network module, performing a second operation to obtain a fifteenth feature and a sixteenth feature output by the second neural network module, wherein the second neural network module is any one of the at least one neural network module;
[0325] The fifteenth feature output by the last neural network module is used as the thirteenth feature, and the sixteenth feature output by the last neural network module is used as the fourteenth feature;
[0326] The second operation includes:
[0327] Using the first projection convolution layer and the spatial convolution layer in the third convolution module to extract the seventeenth feature, so as to obtain the eighteenth feature;
[0328] Performing a first coupling process on the eighteenth feature to obtain a nineteenth feature;
[0329] The feedforward neural network, multi-head attention mechanism and multi-layer perception mechanism in the Transformer encoding layer are used to extract the twentieth feature to obtain the sixteenth feature output by the second neural network module; wherein the twentieth feature is obtained based on the seventeenth feature and the nineteenth feature;
[0330] Performing a second coupling process on the sixteenth feature to obtain a twenty-first feature;
[0331] Using the second projected convolution layer in the third convolution module to extract the eighteenth feature, and adding the seventeenth feature to obtain the twenty-second feature;
[0332] Using the first projected convolution layer in the fourth convolution module to perform convolution processing on the twenty-second feature to obtain a twenty-third feature;
[0333] Performing a third coupling process on the twenty-third feature and the twenty-first feature to obtain the twenty-fourth feature;
[0334] Performing feature extraction on the twenty-fourth feature using the spatial convolution layer and the second projection convolution layer in the fourth convolution module to obtain the fifteenth feature output by the second neural network module;
[0335] Using the second projected convolution layer in the fourth convolution module to extract the fifteenth feature, and adding the seventeenth feature to obtain a twenty-fourth feature;
[0336] Wherein, in the case where the second neural network module is the first neural network module, the seventeenth feature is the second data feature;
[0337] When the second neural network module is not the first neural network module, the seventeenth feature is the fifteenth feature output by the neural network module adjacent to the second neural network module.
[0338] Optionally, the processor 601 is specifically configured to:
[0339] Obtaining a second loss error according to the second training classification result and the second code class file;
[0340] When the second loss error is greater than a second preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the second loss error;
[0341] Return to the step of using the convolution module to extract the second data feature to obtain the thirteenth feature, and using the Transformer encoding layer to extract the second data feature to obtain the fourteenth feature, until the second loss error is less than or equal to the second preset error, and obtain the second Conformer model.
[0342] Optionally, the first coupling process includes:
[0343] Projection convolution processing, average pooling downsampling processing and layer normalization processing.
[0344] Optionally, the second coupling process includes:
[0345] Layer normalization, bicubic interpolation upsampling, and projection convolution.
[0346] Among them, Figure 6 In the embodiment, the bus architecture may include any number of interconnected buses and bridges, specifically linking together various circuits of one or more processors represented by processor 601 and memory represented by memory 603. The bus architecture may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides a user interface 605. The transceiver 604 may be a plurality of components, i.e., including a transmitter and a receiver, providing a unit for communicating with various other devices on a transmission medium. The processor 601 is responsible for managing the bus architecture and general processing, and the memory 603 may store data used by the processor 601 when performing operations.
[0347] A readable storage medium according to an embodiment of the present invention stores a program or instruction thereon. When the program or instruction is executed by a processor, the steps in the file security detection method described above are implemented and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0348] In the embodiment of the present invention, module can be implemented with software so that it can be executed by various types of processors. For example, an executable code module of an identification can include one or more physical or logical blocks of computer instructions, for example, it can be constructed as an object, process or function. Nevertheless, the executable code of the identified module does not need to be physically located together, but can include different instructions stored in different positions, and when these instructions are logically combined together, it constitutes a module and realizes the specified purpose of the module.
[0349] In fact, executable code module can be a single instruction or many instructions, and can even be distributed on a plurality of different code segments, distributed among different programs, and distributed across a plurality of memory devices. Similarly, operating data can be identified in the module, and can be implemented and organized in the data structure of any appropriate type according to any appropriate form. The operating data can be collected as a single data set, or can be distributed in different locations (including on different storage devices), and can only be present on a system or network as an electronic signal at least in part.
[0350] When a module can be implemented by software, considering the level of existing hardware technology, a person skilled in the art can build a corresponding hardware circuit to implement the corresponding function of the module that can be implemented by software without considering the cost. The hardware circuit includes a conventional very large scale integration (VLSI) circuit or gate array and existing semiconductors such as logic chips, transistors, or other discrete components. The module can also be implemented by a programmable hardware device, such as a field programmable gate array, a programmable array logic, a programmable logic device, etc.
[0351] The above exemplary embodiments are described with reference to the accompanying drawings, and many different forms and embodiments are feasible without departing from the spirit and teachings of the present invention. Therefore, the present invention should not be constructed as a limitation of the exemplary embodiments proposed herein. More specifically, these exemplary embodiments are provided so that the present invention will be perfect and complete, and the scope of the present invention will be conveyed to those who are familiar with the technology. In these figures, the component sizes and relative sizes may be exaggerated for clarity. The terms used here are only based on the purpose of describing specific exemplary embodiments and are not intended to be limiting. As used herein, unless the text clearly indicates otherwise, the singular forms "one", "an" and "the" are intended to include these multiple forms. It will be further understood that the terms "including" and / or "comprising" when used in this specification indicate the presence of the features, integers, steps, operations, components and / or components, but do not exclude the presence or increase of one or more other features, integers, steps, operations, components, components and / or their groups. Unless otherwise indicated, when stated, a range of values includes the upper and lower limits of that range and any subranges therebetween.
[0352] A specific embodiment of the present invention further provides a computer program product, including computer instructions, which, when executed by a processor, implement the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0353] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A file security detection method, characterized in that: include: Get the files of the first artificial intelligence AI model project; Using the trained first Conformer model, classify files of the first AI model project to obtain a first classification result of the file type of the first AI model project; According to the first classification result, a corresponding AI scanning plug-in is used to perform a security scan on the files of the first AI model project to obtain a first security detection result of the files of the first AI model project.
2. The method according to claim 1, characterized in that: The method further comprises: According to the first classification result, obtain a first code type file in the files of the first AI model project; Using the trained second Conformer model, classify the first code class file to obtain the target type code field in the first code class file; Perform security scans on different target type code fields using corresponding AI scanning plug-ins to obtain second security detection results of the target type code fields; Based on the first security test result and the second security test result, a final security test result of the first AI model project is obtained.
3. The method according to claim 1, characterized in that Before classifying files of the first AI model project by using the trained first Conformer model to obtain a first classification result of the file type of the first AI model project, the method further includes: Using the second classification result of the file of the second AI model project to train the initial Conformer model, to obtain the first Conformer model; The initial Conformer model includes a convolution module and a Transformer encoding layer.
4. The method according to claim 3, characterized in that The initial Conformer model is trained using the second classification result of the file of the second AI model project to obtain the first Conformer model, including: Performing feature extraction on the second classification result to obtain a first data feature of the second classification result; Using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer encoding layer to extract features from the first data feature to obtain a second feature; Performing pooling classification on the first feature and the second feature respectively to obtain a first training classification result; The first Conformer model is obtained according to the first training classification result and the second classification result.
5. The method according to claim 4, characterized in that The initial Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a first convolution module and a second convolution module; Using the convolution module to extract features from the first data feature to obtain a first feature, and using the Transformer coding layer to extract features from the first data feature to obtain a second feature, including: For a first neural network module, performing a first operation to obtain a third feature and a fourth feature output by the first neural network module, wherein the first neural network module is any one of the at least one neural network module; Using the third feature output by the last neural network module as the first feature, and using the fourth feature output by the last neural network module as the second feature; The first operation includes: Using the first projection convolution layer and the spatial convolution layer in the first convolution module to extract the fifth feature, so as to obtain a sixth feature; Performing a first coupling process on the sixth feature to obtain a seventh feature; The eighth feature is extracted by using the feedforward neural network, the multi-head attention mechanism and the multi-layer perception mechanism in the Transformer encoding layer to obtain the fourth feature output by the first neural network module; wherein the eighth feature is obtained according to the fifth feature and the seventh feature; Performing a second coupling process on the fourth feature to obtain a ninth feature; Using the second projected convolution layer in the first convolution module to extract the sixth feature, and adding the fifth feature to obtain a tenth feature; Using the first projected convolution layer in the second convolution module to perform convolution processing on the tenth feature to obtain an eleventh feature; Performing a third coupling process on the eleventh feature and the ninth feature to obtain a twelfth feature; Using the spatial convolution layer and the second projection convolution layer in the second convolution module to extract the twelfth feature, so as to obtain the third feature output by the first neural network module; Using the second projected convolution layer in the second convolution module to extract the third feature, and adding the fifth feature to obtain a twelfth feature; Wherein, in the case where the first neural network module is the first neural network module, the fifth feature is the first data feature; When the first neural network module is not the first neural network module, the fifth feature is the third feature output by the neural network module adjacent to the first neural network module.
6. The method according to claim 4, characterized in that The first Conformer model is obtained according to the first training classification result and the second classification result, including: Obtaining a first loss error according to the first training classification result and the second classification result; When the first loss error is greater than a first preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the first loss error; Return to the step of using the convolution module to extract the first data feature to obtain the first feature, and using the Transformer encoding layer to extract the first data feature to obtain the second feature, until the loss error is less than or equal to the first preset error, and obtain the first Conformer model.
7. The method according to claim 2, characterized in that Before classifying the first code class file by using the trained second Conformer model to obtain the target type code field in the first code class file, the method further includes: The first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model; Among them, the first Conformer model includes a convolution module and a Transformer encoding layer.
8. The method according to claim 7, characterized in that The first Conformer model is trained using the second code class file in the file of the second AI model project to obtain the second Conformer model, including: Performing feature extraction on the second code class file to obtain a second data feature of the second code class file; Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature; Performing pooling classification on the thirteenth feature and the fourteenth feature respectively to obtain a second training classification result; The second Conformer model is obtained according to the second training classification result and the second code class file.
9. The method according to claim 8, characterized in that The first Conformer model includes at least one neural network module connected in sequence, each of the neural network modules includes a parallel convolution module group and a Transformer encoding layer, and the convolution module group includes a third convolution module and a fourth convolution module; Using the convolution module to extract features from the second data feature to obtain a thirteenth feature, and using the Transformer encoding layer to extract features from the second data feature to obtain a fourteenth feature, including: For a second neural network module, performing a second operation to obtain a fifteenth feature and a sixteenth feature output by the second neural network module, wherein the second neural network module is any one of the at least one neural network module; The fifteenth feature output by the last neural network module is used as the thirteenth feature, and the sixteenth feature output by the last neural network module is used as the fourteenth feature; The second operation includes: Using the first projection convolution layer and the spatial convolution layer in the third convolution module to extract the seventeenth feature, so as to obtain the eighteenth feature; Performing a first coupling process on the eighteenth feature to obtain a nineteenth feature; The feedforward neural network, multi-head attention mechanism and multi-layer perception mechanism in the Transformer encoding layer are used to extract the twentieth feature to obtain the sixteenth feature output by the second neural network module; wherein the twentieth feature is obtained based on the seventeenth feature and the nineteenth feature; Performing a second coupling process on the sixteenth feature to obtain a twenty-first feature; Using the second projected convolution layer in the third convolution module to extract the eighteenth feature, and adding the seventeenth feature to obtain the twenty-second feature; Using the first projected convolution layer in the fourth convolution module to perform convolution processing on the twenty-second feature to obtain a twenty-third feature; Performing a third coupling process on the twenty-third feature and the twenty-first feature to obtain the twenty-fourth feature; Performing feature extraction on the twenty-fourth feature using the spatial convolution layer and the second projection convolution layer in the fourth convolution module to obtain the fifteenth feature output by the second neural network module; Using the second projected convolution layer in the fourth convolution module to extract the fifteenth feature, and adding the seventeenth feature to obtain a twenty-fourth feature; Wherein, in the case where the second neural network module is the first neural network module, the seventeenth feature is the second data feature; When the second neural network module is not the first neural network module, the seventeenth feature is the fifteenth feature output by the neural network module adjacent to the second neural network module.
10. The method according to claim 8, characterized in that According to the second training classification result and the second code class file, the second Conformer model is obtained, including: Obtaining a second loss error according to the second training classification result and the second code class file; When the second loss error is greater than a second preset error, adjusting the model parameters of the convolution module and the model parameters of the Transformer coding layer according to the second loss error; Return to the step of using the convolution module to extract the second data feature to obtain the thirteenth feature, and using the Transformer encoding layer to extract the second data feature to obtain the fourteenth feature, until the second loss error is less than or equal to the second preset error, and obtain the second Conformer model.
11. The method according to claim 5 or 9, characterized in that: The first coupling process comprises: Projection convolution processing, average pooling downsampling processing and layer normalization processing.
12. The method according to claim 5 or 9, characterized in that: The second coupling process comprises: Layer normalization, bicubic interpolation upsampling, and projection convolution.
13. A file security detection device, characterized in that: include: A first acquisition module, used to acquire a file of a first artificial intelligence AI model project; A first processing module, configured to classify files of a first AI model project by using a trained first Conformer model, and obtain a first classification result of the file type of the first AI model project; The second processing module is used to perform a security scan on the files of the first AI model project using a corresponding AI scanning plug-in according to the first classification result, so as to obtain a first security detection result of the files of the first AI model project.
14. A document security detection device, comprising: A transceiver, a processor, a memory, and a program or instruction stored in the memory and executable on the processor; characterized in that when the processor executes the program or instruction, the steps in the file security detection method as described in any one of claims 1 to 12 are implemented.
15. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or instruction is executed by a processor, the steps of the file security detection method according to any one of claims 1 to 12 are implemented.
16. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps in the file security detection method as claimed in any one of claims 1 to 12.
