A method, device and readable storage medium for fine-tuning a large model in the field of security
By introducing the parameter fusion mechanism of containment control and federated learning in the fine-tuning phase of the large model, the problem of data differences between the general large model and the domain large model and the imbalance of the security domain data set are solved, and the generalization and robustness of the model are improved. sex.
Patent Information
- Application Number
- CN202410931827.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-12
AI Technical Summary
Existing domain large models have knowledge gaps and data distribution differences between the data sets in the general large model pre-training stage and the domain large model fine-tuning stage, resulting in poor model generalization, and data sets in the security field often have size imbalance problems. Affects the generalization and robustness of the model.
A large model network dynamic system representation inspired by pinion control is used to deduce the frozen constraints in the fine-tuning stage, and through the parameter fusion mechanism of federated learning, the problem of data set size imbalance is solved, and the generalization and output robustness of the model are improved.
By freezing some nodes or parameters, we optimize the fine-tuning process of large models, improve the model's generalization to domain knowledge, and expand the data set through parameter fusion to balance the impact of event data sets on the model and improve output robustness.
Smart Images

Figure CN118468928B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence large models, and in particular to a large model fine-tuning method, device and readable storage medium in the security field. Background Art
[0002] The statements in this section merely provide background information related to the present disclosure and may not constitute prior art.
[0003] On the one hand, the current construction method of large domain models generally adopts the technical route of fine-tuning general large models with domain knowledge, which means that there is a knowledge gap between the data sets in the pre-training stage of general large models and the data sets in the fine-tuning stage of large domain models, and the data distribution is quite different. How to maintain the basic performance of the general large model while fine-tuning the domain knowledge to make the large model a "domain expert" and improve the generalization of the large model in the face of domain knowledge has become a problem.
[0004] On the other hand, the data sets used in engineering applications in the security field are usually collected based on security events according to the needs of actual engineering and downstream tasks. Data sets based on security events often vary greatly in data volume due to the type of security event, attack method and technical means, and attack duration. For example, APT attacks can last for months or even years and have a wide range of impacts. When doing APT attack correlation analysis, it is often necessary to cover multiple types of data with long time spans such as logs, traffic, and threat intelligence. The amount of data based on this security event will be very large. Previous studies have shown that event-based data sets always have a size imbalance problem in the training phase, which may cause large data sets to manipulate large model prediction outputs, while small data sets have insufficient influence on training large models. Specifically, the large model will generate some outputs that are not related to the event during the inference phase, increasing the probability of "hallucinations" in the large model. Summary of the invention
[0005] The purpose of the present invention is: In response to the above-mentioned existing problems and needs, the present invention provides a method, device and readable storage medium for fine-tuning a large model in the security field, aiming to explore the correlation and optimization methods of different stages of large model training through the integration of interdisciplinary cross-fields, solve the data difference problem between the general large model pre-training data set and the domain large model fine-tuning data set, and the data set imbalance problem that is common in the data set based on security events in the security field; first, inspired by the containment control, a large model network dynamic system representation is constructed; then, the controlled node constraints in the fine-tuning stage are deduced from the perspective of containment control; finally, inspired by federated learning, a large model parameter fusion mechanism is proposed to solve the problem of data set size imbalance and improve the generalization and output robustness of the large model. In summary, the patent of the present invention is novel and effective.
[0006] The technical solution of the present invention is as follows:
[0007] A method for fine-tuning a large model in the security field, comprising:
[0008] Step S1: Inspired by pinning control, construct a large model network dynamic system representation;
[0009] Step S2: deduce the freezing fine-tuning constraint conditions in the large model fine-tuning stage from the perspective of containment control;
[0010] Step S3: Select the fine-tuning freezing scheme that meets the constraints of step S2. Inspired by federated learning, each client fine-tunes the pre-trained model with each event data set, uploads the parameter set of each model to the server for fusion operation, and obtains the first global large model parameter set;
[0011] Step S4: The server sends the merged parameters to each client, increases the number of frozen nodes or parameters according to the controlled conditions of step S2, and makes fine adjustments again;
[0012] Step S5: upload each parameter set to the server for fusion operation to obtain the second global large model parameter set. If the model has not converged or the performance index has not reached the preset standard, continue to iterate the fusion; when the training reaches the preset prerequisite, the fusion iteration ends and the large model parameter set is output.
[0013] Furthermore, the step S1 comprises:
[0014] With N The large model dynamic network with key nodes or parameters is defined as:
[0015]
[0016] in:
[0017] Represents dynamic representation of large model networks;
[0018] represents a continuous function, i.e., the node's self-dynamics, describing the Automatic dynamics of key nodes or parameters;
[0019] Indicates The state of key nodes or parameters, with Dimensional state, expressed as: ,in, Indicates The first key node or parameter Dimensional state, express dimensional real number set; Indicates The status of key nodes or parameters;
[0020] Characterize the coupling strength of the network;
[0021] N Indicates the total number of key nodes or parameters;
[0022] Large model network topology diagram Represents that the node set , edge set ; The Laplacian matrix of the large model network topology is expressed as , Table Matrix Elements of express The set of real numbers, if it exists arrive connection, then ,otherwise ;
[0023] represents a continuous nonlinear function that satisfies the Lipschitz condition and represents the coupling relationship matrix between key nodes or parameters, satisfying ;
[0024] Suppose the network status after fine-tuning is , then:
[0025]
[0026] in:
[0027] Represents the dynamic expression of the network state after fine-tuning;
[0028] Indicates the network status after fine-tuning at the next moment;
[0029] Indicates the network status after fine-tuning;
[0030] represents the initial state of the network after fine-tuning;
[0031] The purpose of containment control is to control some key nodes in the network so that the network reaches the fine-tuned network state. , which makes the network synchronized ; In the large model fine-tuning scenario, the controlled key nodes are the fine-tuning layers or fine-tuning parameters involved in the calculation, and then:
[0032]
[0033] in:
[0034] Indicates the network status before fine-tuning;
[0035] Indicates that time approaches infinity.
[0036] Furthermore, the step S2 comprises:
[0037] Assume that The ratio of freezing the number of layers or parameters in the network, To fine-tune the number of layers or parameters, ; Then, the network state equation is:
[0038]
[0039] in:
[0040] Indicates the number of controlled layers or parameters is Dynamic representation of network status;
[0041] Indicates the number of controlled layers or parameters is The network Laplacian matrix Elements of
[0042] represents the control input or controlled gain, is the control input or controlled gain;
[0043] Indicates the number of controlled layers or parameters is Network status;
[0044] In the large model fine-tuning scenario, the uncontrolled layers or parameters are frozen, that is, the pre-trained values are retained and do not participate in the feedback calculation in the fine-tuning stage. Then:
[0045]
[0046] When the node automatically and coupling strength When , the effectiveness of the control scheme is measured by deleting the rows and columns corresponding to the fixed nodes from the Laplacian matrix of the network, and the minimum characteristic root of the grounded Laplacian is used to measure the effectiveness of the control scheme. That is, the larger the minimum characteristic root, the more effective the control scheme. In the large model fine-tuning scenario, let Controlled, that is Layers or parameters participate in the feedback calculation in the fine-tuning stage, let Delete frozen layers or parameters according to the freezing strategy , The reduced matrix from the corresponding row-column pairs; then, if the following equation holds, the controlled network can reach a synchronized state :
[0047]
[0048] in, , to ensure that the constructed matrix is an M matrix, which is a non-singular matrix with non-positive diagonal elements and whose inverse matrix has all non-negative elements; yes The minimum real part of the characteristic root, whose lower bound is obtained by SchurComplement:
[0049]
[0050] in, For fine-tuning layers or fine-tuning parameters The weight coefficient of It is the maximum distance between the controlled layer or parameter set and the uncontrolled layer or parameter set.
[0051] Furthermore, in the large model fine-tuning scenario, the effectiveness of the frozen fine-tuning strategy can be evaluated from two aspects: the weight coefficient of the fine-tuning layer or the fine-tuning parameter The maximum distance between a controlled layer or parameter set and an uncontrolled layer or parameter set .
[0052] Furthermore, the step S3 includes:
[0053] Step S31: According to the constraints derived in step S2, combined with the fine-tuning scenario and downstream task requirements, select an appropriate fine-tuning stage freezing scheme;
[0054] Step S32: using each local event data set to train a base model framework of the same freezing scheme respectively, to obtain each independent local model;
[0055] Step S33: Upload the parameter sets of each local model to the server via the uplink, perform a fusion operation, and obtain a global large model parameter set of the first fusion iteration.
[0056] Furthermore, the step S4 comprises:
[0057] Step S41: If the performance index of the global large model does not reach the preset standard or the global large model has not converged, the parameter set of the global large model is distributed to each client via a downlink;
[0058] Step S42: Select to continue using the freezing scheme of step S3 according to the model performance, or further increase the number of frozen nodes or parameters according to the constraint conditions of step S2;
[0059] Step S43: Utilize each local event data set to retrain based on the distributed global large model parameter set and start the second round of fusion iteration.
[0060] Furthermore, the fusion operation includes: weighted fusion.
[0061] Furthermore, the step S5 comprises:
[0062] The mathematical description of the parameter fusion iteration mechanism is:
[0063]
[0064] in, and They represent the global large model and the first The parameter set vector of the local model obtained by each client; , represents the total number of iterative fusion, is a set of positive real numbers, and the total number is determined by the preset conditions; Indicates the number of clients; Indicates the weight of each client; Indicates Iteration fusion.
[0065] The present invention also proposes a device for fine-tuning a large model in the security field, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a method for fine-tuning a large model in the security field as described above when executing the computer program.
[0066] The present invention also proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a large model fine-tuning method in the security field as described above are implemented.
[0067] Compared with the prior art, the present invention has the following beneficial effects:
[0068] Inspired by containment control, the present invention introduces the concept of containment control in the control domain into the training of the large model fine-tuning stage, attempting to solve the problem of data differences between the general large model pre-training data set and the domain large model fine-tuning data set, and improve the generalization of large model fine-tuning. At the same time, inspired by federated learning, a model parameter fusion mechanism is proposed to expand the fine-tuning data set in the form of parameters, while solving the problem of data set imbalance and improving the robustness of the model output. Specifically, based on containment control, a dynamic representation of the network system in the large model fine-tuning stage is constructed, and frozen fine-tuning constraints in the large model fine-tuning stage are deduced, attempting to solve the problem of data differences between the large model pre-training data set and the domain large model fine-tuning data set, and improving the generalization of the pre-trained large model to the data set in the fine-tuning stage; inspired by federated learning, a model parameter fusion mechanism combined with frozen fine-tuning constraints is proposed to solve the common data set imbalance problem of data sets based on security events in the security field, and improve the robustness of large model output. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 A flow chart of a method for fine-tuning a large model in the security field;
[0070] Figure 2 Schematic diagram of parameter fusion. DETAILED DESCRIPTION
[0071] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0072] In view of the data discrepancy problem between the general large model pre-training data set and the domain large model fine-tuning data set, this invention is inspired by the idea of containment control and selectively applies control to a small number of nodes in the large model network, so that the entire large model network has the desired behavior, and improves the generalization of the large model in the face of domain knowledge; in view of the common data set imbalance problem in the security field based on security event data sets, inspired by federated learning, the data set is expanded by parameter fusion, the influence of the event data set on the large model fine-tuning is balanced, and the robustness of the large model output is improved. This method attempts to explore the correlation and optimization methods of different stages of large model training through the integration of interdisciplinary cross-fields.
[0073] At present, domain-based large models often adopt the technical route of fine-tuning general open source large models using domain data sets. There is inevitably a data distribution inconsistency and knowledge gap between the base model pre-training data set and the domain knowledge data set. Since the pre-training model has learned a wealth of language representation knowledge, especially when the fine-tuning data set is quite different from the pre-training data set and the number of fine-tuning data sets is limited, the existing fine-tuning methods often use frozen fine-tuning technology to deal with this problem, that is, fine-tuning the last few layers or the first few layers, or fine-tuning some parameters of some layers. In general, fine-tuning the previous layers can use shallow features and general semantic features to better understand basic information and general questions. Fine-tuning the later layers can better capture high-level semantics and domain-specific knowledge, and provide more professional and in-depth answers. Freezing some parameters that contribute little to feedback calculation and have little gradient change can maximize the fine-tuning performance while accelerating the fine-tuning efficiency. However, the specific strategy of freezing fine-tuning often depends on experience, and there is currently no guiding constraint condition for reference. On the other hand, in the field of control, studies have shown that the overall behavior of the network is often dominated by a few key nodes. In order to solve the cost problem of large-scale complex network node control, the concept of pinning control is proposed, which aims to achieve effective synchronization of network status by selectively controlling a small number of key and important nodes in a given network, which is naturally aligned with the requirements of freezing fine-tuning in the large model fine-tuning stage. Inspired by this, this paper attempts to introduce the pinning control theory into the large model fine-tuning stage to generate guiding constraints for freezing fine-tuning.
[0074] In addition, in actual engineering applications in the field of security, the problem of event-based data set size imbalance is common, which may cause a larger data set to manipulate the model prediction output, while a smaller data set has a low influence on joint training. However, the existing data set balancing method based on resampling is not suitable for security threat application scenarios. In this way, it is undoubtedly a challenge to reduce the interference of larger data sets on model prediction without further cleaning the data set itself. Considering that different parameter sets are the key to different models under the same network framework. This shows that the problem of data set size imbalance can be solved from the perspective of parameters. While maintaining data independence and privacy, federated learning has achieved data sharing well, so that all parties involved in training enjoy equal status and achieve common prosperity. Inspired by this, the present invention transforms the training of the joint data set in the fine-tuning stage into the fusion training of the model parameter set. Since the difference in parameter sets comes from the difference in the training data sets used, the model parameter fusion mechanism proposed in the present invention is equivalent to expanding the training data set in the form of parameters. In theory, this parameter fusion mechanism can not only solve the problem of data set imbalance, but also further improve the robustness of the model output.
[0075] The features and performance of the present invention are further described in detail below in conjunction with the embodiments.
[0076] Embodiment 1
[0077] See also Figure 1 , a method for fine-tuning a large model in the security field, specifically comprising the following steps:
[0078] Step S1: Inspired by pinning control, construct a large model network dynamic system representation;
[0079] Step S2: deduce the freezing fine-tuning constraint conditions in the large model fine-tuning stage from the perspective of containment control;
[0080] Step S3: Select the fine-tuning freezing scheme that meets the constraints of step S2. Inspired by federated learning, each client fine-tunes the pre-trained model with each event data set, uploads the parameter set of each model to the server for fusion operation, and obtains the first global large model parameter set;
[0081] Step S4: The server sends the merged parameters to each client, increases the number of frozen nodes or parameters according to the controlled conditions of step S2, and makes fine adjustments again;
[0082] Step S5: upload each parameter set to the server for fusion operation to obtain the second global large model parameter set. If the model has not converged or the performance index has not reached the preset standard, continue iterative fusion; when the training reaches the preset prerequisite, the fusion iteration ends and the large model parameter set is output;
[0083] In this way, the problem of imbalanced event-based dataset size in the fine-tuning phase can be solved, and ultimately a global large model that is better than training with a joint dataset can be obtained.
[0084] In this embodiment, specifically, step S1 includes:
[0085] With N The large model dynamic network with key nodes or parameters is defined as:
[0086]
[0087] in: , , Indicates The state of a node or parameter, with Dimensional state; represents a continuous function, describing the The automatic dynamics of a node or parameter, Satisfies the Lipschitz condition, that is, there is a positive constant , so that ,have ; Characterize the coupling strength of the network, ; N Indicates the total number of key nodes or parameters; large model network topology diagram can be used Represents that the node set , edge set ; It's the network The Laplacian matrix of arrive Connections ,but ,otherwise , ; is a continuous nonlinear function that satisfies the Lipschitz condition and represents the coupling relationship matrix between nodes or parameters. ,when hour, ;
[0088] Suppose the network status after fine-tuning is , then:
[0089]
[0090] The purpose of the control is to control some nodes in the network so that the network can reach a synchronous state. In the large model fine-tuning scenario, the controlled nodes are the fine-tuning layers or fine-tuning parameters involved in the calculation, and then:
[0091]
[0092] in, ;
[0093] Indicates that time approaches infinity.
[0094] In this embodiment, specifically, step S2 includes:
[0095] Assume that The ratio of freezing the number of layers or parameters in the network, To fine-tune the number of layers or parameters, ; Then, the network state equation is:
[0096]
[0097] in, is the control input or controlled gain; in the large model fine-tuning scenario, the uncontrolled layers or parameters are frozen, that is, the pre-trained values are retained and do not participate in the feedback calculation in the fine-tuning stage, then:
[0098]
[0099] Based on the existing research on pinning control, when the node automatically and coupling strength When , the effectiveness of the control scheme is measured by deleting the rows and columns corresponding to the fixed nodes from the Laplacian matrix of the network, and the minimum characteristic root of the grounded Laplacian is used to measure the effectiveness of the control scheme. That is, the larger the minimum characteristic root, the more effective the control scheme. In the large model fine-tuning scenario, let Controlled, i.e. Layers or parameters participate in the feedback calculation in the fine-tuning stage, let Delete frozen layers or parameters according to the freezing strategy , The reduced matrix from the corresponding row-column pairs; then, if the following equation holds, the controlled network can reach a synchronized state :
[0100]
[0101] in, , to ensure that the constructed matrix is an M matrix, which is a non-singular matrix with non-positive diagonal elements and whose inverse matrix has all non-negative elements; The minimum real part of the characteristic root, whose lower bound is obtained by SchurComplement:
[0102]
[0103] in, For fine-tuning layers or fine-tuning parameters The weight coefficient of is the maximum distance between the controlled layer or parameter set and the uncontrolled layer or parameter set; it should be noted that in the large model fine-tuning scenario, Can be set to a learnable coefficient or can be set to ;
[0104] Therefore, in the large model fine-tuning scenario, the effectiveness of the frozen fine-tuning strategy can be evaluated from two aspects: the weight coefficient of the fine-tuning layer or the fine-tuning parameter The maximum distance between a controlled layer or parameter set and an uncontrolled layer or parameter set .
[0105] In this embodiment, specifically, step S3 includes:
[0106] Step S31: According to the constraints derived in step S2, combined with the fine-tuning scenario and downstream task requirements, select an appropriate fine-tuning phase freezing scheme to freeze certain layers or parameters of the base model;
[0107] Step S32: using each local event data set to train a base model framework of the same freezing scheme respectively, to obtain each independent local model;
[0108] Step S33: uploading the parameter sets of each local model to the server via an uplink, performing a fusion operation, and obtaining a global large model parameter set of the first fusion iteration;
[0109] In this embodiment, specifically, the fusion operation includes: weighted fusion;
[0110] That is, the present invention assumes that the data set in the fine-tuning stage consists of four different security events. The model parameter fusion process is as follows: Figure 2 As shown in Figure 1, four different event data sets correspond to four clients, and the final large model corresponds to the server. First, the four local event data sets are used to train the base model framework of the same freezing scheme to obtain four independent local models. Then, the parameter sets of the four local models are used to train the base model framework of the same freezing scheme to obtain four independent local models. Figure 2 The uplink represented by the dotted line is uploaded to the server for fusion operation. Since the four event data sets in the present invention have the same status, that is, each event data set has the same weight value, the present invention adopts weighted average operation to fuse the parameter set. Then, the parameter set of the large global model of the first fusion iteration can be obtained.
[0111] In this embodiment, specifically, step S4 includes:
[0112] Step S41: If the performance index of the global large model does not reach the preset standard or the global large model has not converged, the parameter set of the global large model is distributed to each client via a downlink;
[0113] Step S42: Select to continue using the freezing scheme of step S3 according to the model performance, or further increase the number of frozen nodes or parameters according to the constraint conditions of step S2;
[0114] Step S43: using each local event data set, retraining is performed based on the distributed global large model parameter set to start the second round of fusion iteration;
[0115] That is, if the performance index of the global large model does not reach the preset standard, or the global large model has not converged, the parameter set of the global large model is Figure 2 The downlink represented by the solid line is distributed to four clients. It is worth noting that since the base model has been fine-tuned once and has learned a certain degree of new domain knowledge, we can choose to continue using the freezing scheme in step S3 based on the model performance, or further increase the number of frozen nodes or parameters based on the constraints in step S2. Next, we use the four local event data sets to retrain based on the distributed global large model parameter set and start the second round of fusion iteration.
[0116] In this embodiment, specifically, step S5 includes:
[0117] The mathematical description of the parameter fusion iterative mechanism is:
[0118]
[0119] in, and They represent the global large model and the first The parameter set vector of the local model obtained by each client; represents the total number of iterative fusion, is a set of positive real numbers, and the total number is determined by the preset conditions; Indicates the number of clients; Indicates the weight of each client; Indicates Iteration fusion.
[0120] In this embodiment, four event data sets are taken as an example. ; , , represents the weight of each client. In this embodiment, it is assumed that the four clients have equal status, then ; From the above formula, we can see that the parameter fusion mechanism can be adjusted by The value of makes the model pay specific attention to different data sets, so that a global large model with different attention to different events can be obtained.
[0121] This embodiment also proposes a device for fine-tuning a large model in the security field, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a method for fine-tuning a large model in the security field as described above when executing the computer program; preferably, the computer program can be executable on a terminal device, such as a personal computer.
[0122] This embodiment also proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps of a large model fine-tuning method in the security field as described above; however, the device of the present invention is not limited to this. In this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or device.
[0123] The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more conductors, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0124] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0125] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0126] The above-mentioned embodiments only express the specific implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the protection scope of the present application. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the technical solution concept of the present application, and these all belong to the protection scope of the present application.
[0127] This background section is provided to generally present the context of the invention, and the work of the presently named inventors, the work to the extent described in this background section, and aspects of this section that did not constitute prior art at the time of application are neither explicitly nor implicitly admitted to be prior art to the present invention.
Claims
1. A method for fine-tuning a large model in the security field, characterized in that: include: Step S1: Inspired by pinning control, construct a large model network dynamic system representation; Step S2: deduce the freezing fine-tuning constraint conditions in the large model fine-tuning stage from the perspective of containment control; Step S3: Select the fine-tuning freezing scheme that meets the constraints of step S2. Inspired by federated learning, each client fine-tunes the pre-trained model with each event data set, uploads the parameter set of each model to the server for fusion operation, and obtains the first global large model parameter set; Step S4: The server sends the merged parameters to each client, increases the number of frozen nodes or parameters according to the controlled conditions of step S2, and makes fine adjustments again; Step S5: upload each parameter set to the server for fusion operation to obtain the second global large model parameter set. If the model has not converged or the performance index has not reached the preset standard, continue iterative fusion; When the training reaches the preset prerequisite, the fusion iteration ends and the large model parameter set is output; The step S2 comprises: Assume that The ratio of freezing the number of layers or parameters in the network, To fine-tune the number of layers or parameters, ; Then, the network state equation is: in: Indicates the number of controlled layers or parameters is Dynamic representation of network status; Indicates the number of controlled layers or parameters is The network Laplacian matrix Elements of represents the control input or controlled gain, is the control input or controlled gain; Indicates the number of controlled layers or parameters is Network status; In the large model fine-tuning scenario, the uncontrolled layers or parameters are frozen, that is, the pre-trained values are retained and do not participate in the feedback calculation in the fine-tuning stage. Then: When the node automatically and coupling strength When , the effectiveness of the control scheme is measured by deleting the rows and columns corresponding to the fixed nodes from the Laplacian matrix of the network, and the minimum characteristic root of the grounded Laplacian is used to measure the effectiveness of the control scheme. That is, the larger the minimum characteristic root, the more effective the control scheme. In the large model fine-tuning scenario, let Controlled, that is Layers or parameters participate in the feedback calculation in the fine-tuning stage, let Delete frozen layers or parameters according to the freezing strategy , The reduced matrix from the corresponding row-column pairs; then, if the following equation holds, the controlled network can reach a synchronized state : in, , to ensure that the constructed matrix is an M matrix, which is a non-singular matrix with non-positive diagonal elements and whose inverse matrix has all non-negative elements; yes The minimum real part of the characteristic root, whose lower bound is obtained by Schur Complement: in, For fine-tuning layers or fine-tuning parameters The weight coefficient of is the maximum distance between a controlled layer or parameter set and an uncontrolled layer or parameter set; In the large model fine-tuning scenario, the effectiveness of the frozen fine-tuning strategy can be evaluated from two aspects: the weight coefficient of the fine-tuning layer or the fine-tuning parameter The maximum distance between a controlled layer or parameter set and an uncontrolled layer or parameter set .
2. A method for fine-tuning a large model in the security field according to claim 1, characterized in that: The step S1 comprises: With N The large model dynamic network with key nodes or parameters is defined as: in: Represents dynamic representation of large model networks; represents a continuous function, i.e., the node's self-dynamics, describing the Automatic dynamics of key nodes or parameters; Indicates The state of key nodes or parameters, with Dimensional state, expressed as: ,in, Indicates The first key node or parameter Dimensional state, express dimensional real number set; Indicates The status of key nodes or parameters; Characterize the coupling strength of the network; N Indicates the total number of key nodes or parameters; Large model network topology diagram Represents that the node set , edge set ; The Laplacian matrix of the large model network topology is expressed as , Table Matrix Elements of express The set of real numbers, if it exists arrive connection, then ,otherwise ; represents a continuous nonlinear function that satisfies the Lipschitz condition and represents the coupling relationship matrix between key nodes or parameters, satisfying ; Suppose the network status after fine-tuning is , then: in: Represents the dynamic expression of the network state after fine-tuning; Indicates the network status after fine-tuning at the next moment; Indicates the network status after fine-tuning; represents the initial state of the network after fine-tuning; The purpose of containment control is to control some key nodes in the network so that the network reaches the fine-tuned network state. , that is, to synchronize the network ; In the large model fine-tuning scenario, the controlled key nodes are the fine-tuning layers or fine-tuning parameters involved in the calculation, and then: in: Indicates the network status before fine-tuning; Indicates that time approaches infinity.
3. A method for fine-tuning a large model in the security field according to claim 2, characterized in that: The step S3 comprises: Step S31: According to the constraints derived in step S2, combined with the fine-tuning scenario and downstream task requirements, select an appropriate fine-tuning stage freezing scheme; Step S32: using each local event data set to train a base model framework of the same freezing scheme respectively, to obtain each independent local model; Step S33: Upload the parameter sets of each local model to the server via the uplink, perform a fusion operation, and obtain a global large model parameter set of the first fusion iteration.
4. A method for fine-tuning a large model in the security field according to claim 3, characterized in that: The step S4 comprises: Step S41: If the performance index of the global large model does not reach the preset standard or the global large model has not converged, the parameter set of the global large model is distributed to each client via a downlink; Step S42: Select to continue using the freezing scheme of step S3 according to the model performance, or further increase the number of frozen nodes or parameters according to the constraint conditions of step S2; Step S43: Utilize each local event data set to retrain based on the distributed global large model parameter set and start the second round of fusion iteration.
5. A method for fine-tuning a large security model according to claim 4, characterized in that: The fusion operation includes: weighted fusion.
6. A method for fine-tuning a large security model according to claim 5, characterized in that: The step S5 comprises: The mathematical description of the parameter fusion iterative mechanism is: in, and They represent the global large model and the first The parameter set vector of the local model obtained by each client; , represents the total number of iterative fusion, is a set of positive real numbers, and the total number is determined by the preset conditions; Indicates the number of clients; Indicates the weight of each client; Indicates Iteration fusion.
7. A large model fine-tuning device for the safety field, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a method for fine-tuning a large model in the security field as described in any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of a method for fine-tuning a large model in the security field as described in any one of claims 1 to 6 are implemented.
