Neural network model co-evolution method based on model modularization and model merging

Through a neural network model collaborative optimization framework based on model modularization and model merging, the problem of difficulty in knowledge integration in continuous training of deep neural network models is solved, the independent upgrade of functional modules and global knowledge fusion are realized, and multi-task performance and computing efficiency are improved.

CN120805989APending Publication Date: 2025-10-17BEIHANG UNIV +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510980096.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing deep neural network models find it difficult to effectively integrate new knowledge during continuous training. The isolation of knowledge between modules makes collaborative evolution difficult, and fine-tuning of all parameters destroys the functional partitioning of the pre-trained model, resulting in poor knowledge fusion effects and high consumption of computing resources.

Method used

A neural network model collaborative optimization framework based on model modularization and model merging is adopted. Modular decomposition is performed through gradient search and dual-index optimization. Combined with the sparse task vector fusion mechanism, independent upgrade of functional modules and global knowledge fusion are achieved.

Benefits of technology

It improves the maintainability and adaptability of the model in multi-task scenarios, reduces computing costs, improves reasoning speed and multi-task performance, and realizes continuous evolution of the model and efficient knowledge transfer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120805989A_ABST
    Figure CN120805989A_ABST
Patent Text Reader

Abstract

The invention provides a neural network model co-evolution method based on model modularization and model merging, and belongs to the field of artificial intelligence. Comprising the following steps: (1) carrying out model modular decomposition based on gradient search; and through common optimization of a weight retention rate index and a performance index on a field pre-training set, extracting a function-related sparse module from the pre-training model. And (2) the module only updates the specific weight on the downstream task, so that knowledge updating is carried out on the specific field. And (3) knowledge fusion based on model merging. A sparse task vector is directly obtained by subtracting the weights of the fine-tuned modules from the weights of the pre-training models, and then a sparse weight updating matrix among the multiple modules is added back to the pre-training weights, so that a multi-task global model is obtained. According to the method, the mapping relation between neural network parameters and functions is defined, the model co-evolution effect is improved, and parameter conflicts in multi-task learning are relieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application provides a neural network model collaborative evolution method based on model modularization and model merging, and belongs to the field of artificial intelligence. BACKGROUND

[0002] With the rapid development of deep learning, the pre-training-fine-tuning paradigm has become the mainstream technology in the field of natural language processing and computer vision. Through pre-training on massive data and fine-tuning on specific tasks, the model can adapt to the diverse needs of downstream applications, and then a large number of specialized fine-tuning models are produced. Although existing research attempts to fuse and transfer knowledge among these fine-tuning models through model merging and other methods, the full fine-tuning they rely on often destroys the original functional partition of the pre-training model, making it difficult to effectively integrate new knowledge after fine-tuning, and the fine-tuning cost is relatively high. These two points make it a great challenge for efficient collaborative evolution among models. Therefore, it is of great research significance and application value to study how to more effectively integrate the knowledge scattered in various fine-tuning models, so that the neural network model can be effectively optimized to achieve effective and low-cost multi-task learning and knowledge transfer, in order to improve the model's generalization ability, reduce the cost of repeated training, and promote the development of artificial intelligence towards more generalization.

[0003] The current mainstream technical solutions all adopt the "full fine-tuning + post-optimization" paradigm, that is, first obtain a task-specific model through fine-tuning, and then eliminate knowledge conflicts through weight interpolation, parameter pruning and other means. Specifically, there are three technical paths: 1) Weight averaging, which aggregates multiple models at the parameter level to promote the model's generalization ability and rapid adaptability. For example, Average Merging directly performs arithmetic averaging on the parameters of multiple fine-tuned models to construct a multi-task model; 2) Task vector merging, which obtains task vectors by subtracting pre-training parameters from the parameters of multiple fine-tuned models, and then uses task vectors to transfer multi-task knowledge to the model. On this basis, many methods sparsify the task vectors to reduce conflicts between tasks, so that the model can better integrate multi-task knowledge. Although there are parameter efficient fine-tuning (PEFT) to adapt to downstream tasks, the common practice is to introduce new and independent modules to learn and store new task knowledge. This method isolates new knowledge in fixed modules and cannot effectively aggregate learned new knowledge to evolve the model.

[0004] Although the above mainstream technical solutions have shown certain effects in improving the multi-task processing ability and collaborative optimization of the model, the "full parameter fine-tuning and optimization" path they rely on has some structural defects that are difficult to overcome, thereby limiting its ultimate performance ceiling. A core problem is that the full parameter fine-tuning process often directly updates all parameters inside the model, which inevitably destroys the dedicated processing areas (i.e., functional partitions) for different semantic or functional features that the model has spontaneously formed through large-scale data learning in the pre-training phase. Since existing knowledge fusion schemes are mostly built on these full parameter fine-tuned models, the disordered functional partitions fundamentally weaken the effectiveness of subsequent knowledge fusion. As for different methods, direct weight averaging often appears rough and limited in fusion effect due to insufficient consideration of the importance differences of different parameters in different tasks. While those methods that try to analyze and weight parameter importance by introducing additional data sets may improve fusion accuracy, they often bring significant computational resource consumption. As for the task vector method, although it aims to fuse knowledge by calculating and sparsifying task vectors, since the consistency of the internal functional partitions of each model has been broken in the independent fine-tuning process, the subsequent parameter alignment and conflict resolution process necessary to merge these heterogeneous task vectors not only increases additional processing costs, but also often fails to achieve satisfactory performance in actual performance, failing to completely solve the problem of knowledge conflict. SUMMARY

[0005] The present application aims to solve the problem that existing deep neural network models are difficult to effectively integrate new knowledge in continuous training, and the knowledge isolation between modules leads to difficulty in collaborative evolution. A model collaborative optimization framework based on model modularization and model merging technology is proposed, aiming to realize independent upgrade of model functional modules and global knowledge fusion. This framework introduces the concept of software engineering modularization into the neural network evolution process, breaking through the limitations of traditional parameter coupling architecture, and has important theoretical significance for promoting continuous evolution of models and improving the maintainability and adaptability of large models in multi-task scenarios. At the same time, it provides a new technical path for efficient inference in edge computing scenarios.

[0006] Specifically, the following key problems are mainly solved: (1) the problem of unclear mapping relationship between neural network parameters and functions, a modular training strategy based on double index optimization is proposed, and the function related parameters are accurately located by joint optimization of cross entropy loss and weight retention rate; (2) the existing modular method only realizes model decoupling and lacks knowledge feedback mechanism, and the present invention realizes the reverse update of the knowledge of the downstream module to the original model by constraining the gradient in the fine-tuning process through the weight mask obtained by modularization, so that the model can benefit from the downstream task; (3) the parameter conflict problem in multi-task knowledge update, a sparse task vector fusion method is obtained by modular fine-tuning, and the knowledge interference is reduced by weighted combination strategy, so that the model performance is effectively improved after multi-round evolution.

[0007] The neural network model cooperative evolution method based on model modularization and model merging comprises the following steps:

[0008] (1) Model modularization decomposition based on gradient search. Through the weight retention rate index and the performance index on the domain pre-training set, two indexes are optimized together to extract the function related sparse module from the pre-training model.

[0009] (2) Parameter constraint optimization and knowledge accumulation of the module on the specific downstream task. The module is updated only for specific weights on the downstream task, so as to update the knowledge for specific fields.

[0010] (3) Knowledge fusion based on model merging. The sparse task vector is directly obtained by subtracting the weight of the fine-tuned module from the pre-training model weight, and then the sparse weight update matrix between multiple modules is added back to the pre-training weight, so as to obtain a multi-task global model.

[0011] The method of each step is as follows:

[0012] (1) Modular decomposition based on gradient search;

[0013] The target of modular decomposition is to obtain a module that can make good prediction in a specific field, and the module only retains the weights related to the field in the original model, which promotes the subsequent knowledge transfer process. The problem of modularization is described as selectively retaining the weights related to the target field from all model weights, and setting other weights to 0. The weights of 0 will not affect the prediction result, which is equivalent to deleting the weight.

[0014] This process is formalized as a combination optimization problem based on a binary mask vector, where the mask is defined as: M∈{0,1} Lwhere L denotes the number of parameters of the original model, and the mask is 1 for keeping the model weight and 0 for removing the weight. Then the model weights related to the task are kept and the irrelevant weights are set to 0 by element-wise multiplication of the mask and the model weights, i.e. ' W = W M, where denotes the Hadamard product.

[0015] In the optimization process of the mask, the core goal is to find the optimal mask configuration corresponding to the candidate module, which is characterized in two aspects: one is to keep only the weight parameters closely related to the target task, and the other is to be able to exhibit superior performance on the target task. To achieve this goal, the system adopts a double-index evaluation strategy, and defines the optimization objective function as the weighted sum of the cross-entropy loss and the weight retention rate. The cross-entropy loss is used to measure the performance of the module on a specific task, and the weight retention rate is used to measure the number of weights retained by the candidate module.

[0016] Specifically, a subset closely related to the target function is selected from the pre-training data set, and a domain-specific data set is constructed as a guide signal for mask optimization. Then the original model weights are multiplied element-wise with the current mask, and part of the original weights are removed to obtain a candidate module. Then the candidate module is used to make predictions on the target data set, thereby obtaining the MLM (Masked Language Model) loss on the target data, whose calculation formula is as follows:

[0017]

[0018] where K is the position index set of the covered tokens, |K| is the total number of covered tokens, x i is the original token at position i (i.e. the true label), x masked is the input sequence after covering processing, P(x i | x masked ) is the probability of the model predicting the original token x i at position i given the context after covering. A low cross-entropy loss indicates that the module still performs well on the pre-training task, indicating that the module retains more weights closely related to the target domain. Secondly, the weight retention rate is directly calculated from the mask M: where N denotes the number of weights in the original model. A low weight retention rate indicates that the number of weights retained by the temporary module accounts for a small proportion of the total number of weights. The objective function of mask optimization is where a is the weighting coefficient; by optimizing the objective function, the gradient descent algorithm can continuously optimize the mask, and ultimately achieve the best trade-off between model sparsity and target task prediction performance.

[0019] In the process of model mask optimization, the search space complexity presents an exponential explosion challenge. Specifically, when the mask space is defined as a binary vector M ∈ {0, 1} L , its theoretical search size reaches 2 L L, where L is the number of model parameters. A gradient-based search method is adopted, that is, in each round of search, according to the objective function value of the candidate mask of the last round, a new candidate mask with smaller objective function value is found by gradient descent method. At the same time, by introducing a continuity parameter W to replace the original discrete mask, the discrete optimization problem is converted into a continuous differentiable form, so that the mask can be iteratively updated. W represents the relevance of the corresponding weight to the target task. At the time of evaluation, an indicator function is used to convert it into a binary mask.

[0020] The specific mask update equation is: where η is the learning rate, α is the sparsity adjustment factor, and M is the modular candidate mask. The mask is updated by gradient descent, and the objective function is constantly fed back; finally, the gradient descent generates independent modules covering different fields, each module only retains part of the weights of the original model, forming a highly sparse and function-specific subnetwork.

[0021] (2) Parameter constraint optimization and knowledge accumulation of modules on specific downstream tasks;

[0022] A parameter constraint-based directional optimization mechanism is used to realize directional accumulation of knowledge.

[0023] In specific implementation, first, based on the binary mask matrix M obtained by decomposing the pre-trained model, a parameter update whitelist is constructed for each downstream task. In the back propagation process, the system uses gradient gating technology to implement hard freezing of non-whitelist parameters, so that only the parameters corresponding to the mask are updated. Specifically, first, identify each layer mask. When the parameter set of a certain hidden layer of the module mask matrix M is all 0, set the requires_grad attribute of all Parameter objects in that layer to False. For mixed layers with some active parameters, dynamic gradient masking is implemented: in the back propagation process, by rewriting the optimizer function, the model is implemented with gradient masking operation, that is, grad i = grad i ⊙ M i , where grad i represents the corresponding gradient of the model weight.

[0024] (3) Knowledge fusion based on model merging;

[0025] In the knowledge updating process, the feedback of the new knowledge of the module to the global model is realized through a sparse task vector fusion mechanism. t t -θ0, wherein M t is a binary mask obtained through modular training, which accurately identifies the core parameter region related to the task.

[0026] In the fusion stage, the system combines the tth task vector by weighting according to the domain relevance coefficient λ_t, and then the global model parameters are fused through θ multi = θ0+∑λ t Δθ t The final fusion formula is:

[0027]

[0028] And the validation set is used to adaptively adjust λ t , maximizing the multi-task performance. To optimize the fusion effect, the system uses a validation set-driven adaptive parameter adjustment strategy: grid search is performed in the [0, 1.3] interval with a step size of 0.1, and the λ combination that minimizes the multi-task joint loss is selected to ensure that the knowledge fusion effect is optimal.

[0029] The present application has the following characteristics:

[0030] 1. The present application is a model collaborative reuse framework based on modularization, mainly including the following three parts: "model modularization based on gradient search", "parameter constraint optimization and knowledge accumulation of modules on specific downstream tasks", and "knowledge fusion based on model merging".

[0031] 2. In the "modular decomposition based on gradient search" part, the present application realizes the functional modular decomposition of the model through gradient search, and disassembles the pre-trained model into high-cohesion sparse sub-networks. The core is to design a mask-optimized loss function, and dynamically optimize the mask through gradient descent, so as to filter the weights strongly related to the target field, and set the irrelevant parameters to zero to form a function-specific module.

[0032] 3. In the "fusion of multi-task knowledge" part, the present application realizes the feedback and upgrading of the module knowledge to the global model through sparse task vector fusion. The fine-tuning trajectory of each module is encoded as a sparse parameter increment, which is combined with the function partition identified by its mask and weighted fused into the base model according to the domain relevance coefficient λ. The parameter increments of different tasks overlap greatly, which effectively avoids the conflicts in the full parameter fusion of existing methods.

[0033] The technical scheme of the present application introduces a collaborative optimization framework of modular design and combination, which brings the following beneficial effects:​

[0034] 1. Clarified the mapping relationship between neural network parameters and functions: To address the unclear mapping relationship between neural network parameters and functions, this paper adopts modular decomposition based on gradient search. Through dual-index optimization (cross entropy loss and weight retention rate), it accurately locates parameters related to specific functions and forms a highly cohesive sparse subnetwork (module). This provides a new technical path for efficient inference on edge devices, effectively reducing the cost of edge device inference and improving the inference speed.

[0035] 2. Improved model co-evolution: Addressing the lack of knowledge feedback mechanisms in existing modularization approaches, this invention achieves independent upgrades of model functional modules and global knowledge integration through a closed-loop mechanism of "modular decomposition - independent optimization - knowledge feedback." This allows the model to continuously benefit from downstream tasks and promotes continuous model evolution.

[0036] 3. Effectively mitigates parameter conflicts in multi-task learning: To address the parameter conflict issue in multi-task knowledge updates, this paper adopts a modular task vector fusion mechanism. By decoupling the parameter update trajectory of each module into a sparse task vector and combining it with a functional partition mask for weighted fusion, knowledge updates from different domains are isolated in the parameter space. This allows parameters to be superimposed in a mutually exclusive coordinate domain, like a jigsaw puzzle, avoiding the overlap conflicts associated with traditional full parameter fusion. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 This is the overall workflow diagram of ModularEvo of the present invention. DETAILED DESCRIPTION

[0038] This paper proposes a neural network model co-evolution method based on model modularization and model merging, and a neural network model co-optimization framework based on model modularization and model merging (ModularEvo), which aims to solve the problems of knowledge conflict, parameter redundancy and low efficiency of edge reasoning in the continuous evolution process of traditional models. The core workflow framework of this invention is as follows Figure 1 As shown in the figure, the framework realizes the co-evolution of models and functional modules through the closed-loop mechanism of "modular decomposition-independent optimization-knowledge feedback".

[0039] The core processes include:

[0040] (1) Model modular decomposition based on gradient search. By jointly optimizing the weight retention rate metric and the performance metric on the domain pre-training set, we extract functionally relevant sparse modules from the pre-trained model.

[0041] (2) Parameter constraint optimization and knowledge accumulation of modules on specific downstream tasks. Modules are only updated for specific weights on downstream tasks, thereby updating knowledge for specific domains.

[0042] (3) Knowledge fusion based on model merging. By subtracting the weights of the fine-tuned modules from the pre-trained model, a sparse task vector is obtained. Then, the sparse weight update matrix between multiple modules is added back to the pre-trained weights to obtain a multi-task global model.

[0043] This architecture supports multiple rounds of iterative evolution, significantly reducing edge device inference while improving model multi-task performance. The details of the above steps are described below.

[0044] (1) Modular decomposition based on gradient search

[0045] The goal of modular decomposition is to obtain a module that can make good predictions in a specific domain, and only retains the weights of the original model related to that domain. This can effectively facilitate the subsequent knowledge transfer process. Here, the modularization problem can be formulated as selectively retaining the weights related to the target domain from all model weights, while setting other weights to 0. The weights set to 0 will not affect the prediction results, which is equivalent to deleting the weight. This process can be formalized as a combinatorial optimization problem based on a binary mask vector, where the mask is defined as: M ∈ {0, 1} L where L represents the parameter quantity of the original model, and 1 in the mask indicates that this part of the model weight is retained, and 0 indicates that the weight is removed. Then, by element-wise multiplication of the mask and the model weight, the task-related model weight is retained, and the irrelevant weight is set to 0, i.e. W ' = W ⊙ M, where ⊙ represents the Hadamard product. This mechanism has the advantage of architecture independence and can be widely applied to various neural network structures such as Transformers and CNNs, achieving precise pruning of parameter space while ensuring task performance.

[0046] In the optimization process of the mask, the core goal is to find the optimal mask configuration, which corresponds to the candidate module. Its characteristics are reflected in two aspects: one is to retain only the weight parameters closely related to the target task, and the other is to exhibit superior performance on the target task. To achieve this goal, the system uses a dual-index evaluation strategy, defining the optimization objective function as the weighted sum of cross-entropy loss and weight retention rate. The cross-entropy loss is used to measure the performance of the module on the specific task, and the weight retention rate is used to measure the number of weights retained by the candidate module.

[0047] Specifically, the application screens a subset (such as legal text, mathematical problems, code snippets) strongly related to the target function from the pre-training data set, and constructs a field-specific data set as a guide signal for mask optimization. Then the original model weight is multiplied by the current mask element by element, and part of the original weight is removed to obtain a candidate module. Then the candidate module is used to predict on the target data set, so as to obtain the MLM (Masked Language Model) loss on the target data, and the calculation formula is as follows:

[0048]

[0049] Where K is the position index set of the covered word, |K| is the total number of covered words, x i is the original word (i.e. the true label) at position i, x masked is the input sequence after covering processing, P(x i | x masked ) is the probability of the model predicting the original word x i at position i under the condition of the given covering context. Lower cross-entropy loss indicates that the module can still perform well on the pre-training task, further indicating that the module retains more weights closely related to the target field. Secondly, the weight retention rate is directly calculated from the mask M: Where N represents the number of weights in the original model. Lower weight retention rate indicates that the number of weights retained by the temporary module accounts for a small proportion of the total number of weights. Therefore, the objective function of the mask optimization is (alpha is the weighting coefficient). Through the optimization of the objective function, the gradient descent algorithm can continuously optimize the mask, and finally achieve the best trade-off between model sparsity and target task prediction performance.

[0050] In the process of model mask optimization, the search space complexity presents an exponential explosion of serious challenges. Specifically, when the mask space is defined as a binary vector M∈{0,1} L (L is the number of model parameters), the theoretical search size reaches 2 L possible configurations. For modern large neural networks (L≥1e8), this exponential complexity (2 1e8 ≈10 30,000,000) has completely exceeded the processing capacity of conventional optimization methods (such as brute force search). Therefore, the present application adopts a gradient-based search method, that is, by finding a new candidate mask with a smaller objective function value in each round of search according to the objective function value of the last round of candidate mask through gradient descent method. At the same time, by introducing a continuity parameter W instead of the original discrete mask, the discrete optimization problem is converted into a continuous differentiable form, so that the mask can be effectively iterated and updated. The parameter w can represent the correlation between the corresponding weight and the target task to some extent. When evaluating, the indicator function is used to convert it into a binary mask.

[0051] The specific mask update equation is: Where η is the learning rate, α is the sparsity adjustment factor, and M is the modular candidate mask. The mask is updated by gradient descent, and the objective function is constantly fed back, which together drives the model to achieve greater parameter sparsity while maintaining certain task performance. Finally, through gradient descent, independent modules covering different fields (such as law, mathematics, programming) are generated, each module retaining only part of the original model's weights, forming a highly sparse, function-specific subnetwork.

[0052] (2) Parameter constraint optimization and knowledge accumulation of modules on specific downstream tasks;

[0053] The goal of this step is to fine-tune the model for a specific downstream task, on the one hand, to make the module accurately adapt to the new task requirements without destroying the functional partition formed by pre-training, on the other hand, to effectively accumulate local knowledge updates. Taking the two different tasks of legal consultation and mathematical reasoning as an example, when the legal module needs to learn the latest tax law provisions, its parameter update should focus on legal entity recognition, clause relevance modeling, and other specific functional areas. When the mathematical module needs to enhance its symbolic operation capabilities, it needs to focus on optimizing weights related to logical deduction and formula analysis. If traditional full-parameter fine-tuning is used, the gradient updates of the two types of tasks will have directional conflicts in the shared parameter space, causing the model to fall into a state of "catastrophic forgetting" or knowledge confusion. Therefore, the present application adopts a directional optimization mechanism based on parameter constraints to achieve directional accumulation of knowledge.

[0054] In a specific implementation, the application first decomposes the binary mask matrix M obtained based on the pre-trained model to construct a parameter update whitelist for each downstream task. For example, in the legal task module, M locks 75% of the weights unrelated to the legal field through functional partition analysis in the pre-training stage, and only about 25% of the parameters are opened for gradient update. During backpropagation, the system uses gradient gating technology to implement hard freezing of non-whitelist parameters, so that only the parameters corresponding to the module mask are updated. Specifically, the application first identifies each layer mask. When the parameter set of a certain hidden layer of the module mask matrix M is all 0, the requires_grad attribute of all Parameter objects in that layer is set to False, which reduces the computational cost of the model to a certain extent during fine-tuning. For mixed layers with some active parameters, dynamic gradient masking is implemented: during backpropagation, the optimizer function is rewritten to implement gradient masking for the model, i.e. i = grad i ⊙M i , where grad i represents the corresponding gradient of the model weight. In this way, the model fine-tuning cost can be reduced as much as possible while ensuring that irrelevant parameters remain unchanged during optimization.

[0055] This way of fine-tuning part of the model's weights can maintain the functional partition that occurs during pre-training by limiting the update area of the parameters. At the same time, the parameter update is concentrated in the subnetwork highly related to the task to avoid interference with other knowledge.

[0056] (3) Knowledge fusion based on model merging;

[0057] The goal of this step is to merge the new knowledge of the module into the global model to improve multi-task capability. During knowledge update, the application implements feedback of the new knowledge of the module to the global model through a sparse task vector fusion mechanism. Specifically, after completing downstream task fine-tuning, the parameter update trajectory of each module is decoupled into a sparse task vector Δθ t = θ t - θ0, where M t is a binary mask obtained through modular training, which accurately identifies the core parameter area related to the task. Taking the legal question answering and mathematical reasoning dual-task scenario as an example: the legal module locks the attention mechanism and feedforward layer parameters related to text understanding through the mask, while the mathematical module focuses on the matrix operation weights related to logical reasoning. During the fusion stage, the system combines the t-th task vector by weighting the domain relevance coefficient λ t , and then the global model parameters are updated as θ multi = θ0+∑λ t Δθ tThe fusion is completed. The final fusion formula is:

[0058]

[0059] And through the validation set adaptive adjustment lambda t , maximize multi-task performance. To optimize the fusion effect, the system uses a validation set driven adaptive parameter adjustment strategy: grid search in the [0, 1.3] interval with a step size of 0.1, select the lambda combination that minimizes the multi-task joint loss, ensure that the knowledge fusion effect is optimal.

[0060] The advantage of this scheme comes from the decoupling of the parameter space brought about by modularization. The functional partition mask formed in the pre-training stage essentially constructs a functional partition of the parameter space, which promotes the text understanding ability of the legal module and the symbolic reasoning ability of the mathematical module to be isolated in the weight space. This structural sparse feature enables different domain knowledge updates to be like a jigsaw puzzle when multi-task fusion is performed, with parameter superposition being completed in non-interfering coordinate domains. Compared with the weight conflicts generated by traditional full-parameter fusion (such as Task Arithmetic), the modularization mechanism achieves synergy through weight space isolation. Taking the mathematical and legal processing scenarios as examples, the masks of the mathematical module and the legal module cover different subspaces of the weight matrix, respectively, and when fused, the bilingual abilities of the two form a complement in the parameter tensor, rather than overlapping each other. This mechanism not only avoids task conflicts, but also achieves precise regulation of knowledge contribution degree through the lambda t coefficient, enabling the global model to maintain balanced development of multi-domain capabilities in continuous evolution.

[0061] The present application contains some custom-defined parameters in the process of model collaborative optimization, including modular sparse adjustment factor and model scaling factor, etc. These parameters can be replaced by other numerical values or generated by heuristic methods according to actual needs.

Claims

1. A neural network model co-evolution method based on model modularization and model merging, characterized by: The following steps are involved: (1) Model modular decomposition based on gradient search; by jointly optimizing the weight retention rate metric and the performance metric on the domain pre-training set, functionally relevant sparse modules are extracted from the pre-trained model; (2) Parameter constraint optimization and knowledge accumulation of the module on specific downstream tasks; the module only updates specific weights on downstream tasks, thereby updating knowledge in specific fields; (3) Knowledge fusion based on model merging: By subtracting the weights of the fine-tuned module from the pre-trained model, the sparse task vector is directly obtained, and then the sparse weight update matrix between multiple modules is added back to the pre-trained weight to obtain a multi-task global model.

2. The neural network model co-evolution method based on model modularization and model merging according to claim 1, characterized in that: The specific method of step (1) is as follows: the modularization problem is formulated as selectively retaining the weights related to the target domain from all model weights, and resetting the other weights to 0. The weights of 0 will no longer affect the prediction results, which is equivalent to deleting the weights. The process is formalized as a combinatorial optimization problem based on a binary mask vector, where the mask is defined as: M∈{0,1} L , where L represents the number of parameters of the original model, a mask of 1 means retaining this part of the model weight, and 0 means removing the weight; then, by element-wise multiplication of the mask and the model weight, the task-related model weight is retained and the irrelevant weight is reset to 0, that is, W ' =W⊙M, where ⊙ represents the Hadamard product; During mask optimization, the core goal is to find the optimal mask configuration. This mask corresponds to the candidate module and has two key characteristics: first, retaining only weight parameters that are closely related to the target task, and second, achieving superior performance on the target task. To achieve this, the system adopts a dual-metric evaluation strategy, defining the optimization objective function as the weighted sum of the cross-entropy loss and the weight retention rate. The cross-entropy loss measures the module's performance on a specific task, while the weight retention rate measures the number of weights retained by the candidate module. Specifically, a subset that is strongly correlated with the target function is selected from the pre-training dataset, and a domain-specific dataset is constructed as a guiding signal for mask optimization. The original model weights are then multiplied element-wise by the current mask, and some of the original weights are removed to obtain a candidate module. The candidate module is then used to make predictions on the target dataset to obtain the MLM loss on the target data, which is calculated as follows: Where: K is the position index set of the masked word, |K| is the total number of masked words, x i is the original word at position i, i.e. the true label, x masked is the input sequence after masking, P(x i ∣x masked ) is the condition where the model predicts the original word x at position i given the masked context i The low cross entropy loss indicates that the module can still perform well on the pre-training task, indicating that the module retains more weights that are closely related to the target domain; secondly, the weight retention rate is directly calculated by the mask M: Where N represents the number of weights in the original model; a low weight retention rate indicates that the number of weights retained by the temporary module accounts for a small proportion of the total weights; the objective function of mask optimization is α is the trade-off coefficient; by optimizing this objective function, the gradient descent algorithm can continuously optimize the mask and ultimately achieve the best trade-off between model sparsity and target task prediction performance; In the process of model mask optimization, the search space complexity presents a severe challenge of exponential explosion; specifically, when the mask space is defined as a binary vector M∈{0,1} L When the theoretical search scale reaches 2 L possible configurations, where L is the number of model parameters. A gradient-based search method is used, that is, in each round of search, a new candidate mask with a smaller objective function value is found through gradient descent based on the objective function value of the candidate mask in the previous round. At the same time, by introducing a continuity parameter W to replace the original discrete mask, the discrete optimization problem is transformed into a continuous and differentiable form, allowing the mask to be iteratively updated. W represents the correlation between the corresponding weight and the target task. During evaluation, an indicator function is used to convert it into a binary mask. The specific mask update equation is: Where η is the learning rate, α is the sparsity adjustment factor, and M is the modular candidate mask; the mask is updated through gradient descent, and then continuously fed back through the objective function; finally, independent modules covering different fields are generated through gradient descent, and each module only retains part of the weight of the original model, forming a highly sparse and functionally specialized sub-network.

3. The neural network model co-evolution method based on model modularization and model merging according to claim 1, characterized in that: The specific method of step (2) is: adopting a directional optimization mechanism based on parameter constraints to achieve directional accumulation of knowledge; First, based on the binary mask matrix M obtained by decomposing the pre-trained model, a parameter update whitelist is constructed for each downstream task. During the backpropagation process, the system uses gradient gating technology to hard freeze non-whitelist parameters, so that only the parameters corresponding to the module mask are updated. Specifically, each layer mask is first identified; When all the hidden layer parameters of the module mask matrix M are 0, the requires_grad attribute of all Parameter objects of the layer is directly set to False; for the mixed layer with some active parameters, dynamic gradient masking is implemented: in the back propagation process, the gradient masking operation is implemented on the model by rewriting the optimizer function, that is, grad i =grad i ⊙M i , where grad i Represents the corresponding gradient of the model weight.

4. The neural network model co-evolution method based on model modularization and model merging according to claim 1, characterized in that: The specific method of step (3) is: In the knowledge updating process, the new knowledge of the module is fed back to the global model through the sparse task vector fusion mechanism. Specifically, after each module completes the downstream task fine-tuning, its parameter update trajectory is decoupled into a sparse task vector Δθ t =θ t -θ0, where M t It is a binary mask obtained through modular training, which accurately identifies the core parameter areas related to the task; In the fusion stage, the system performs a weighted combination of the t-th task vector according to the domain correlation coefficient λ_t, and then the global model parameters are calculated by θ multi =θ0+∑λ t Δθ t Complete the fusion; the final fusion formula is: And adaptively adjust λ through the validation set t , maximize multi-task performance; to optimize the fusion effect, the system adopts a validation set-driven adaptive parameter adjustment strategy: a grid search is performed in the interval [0,1.3] with a step size of 0.1, and the lambda combination that minimizes the multi-task joint loss is selected to ensure the optimal effect of knowledge fusion.

Citation Information

Cited By

  • Image data processing method and system based on lightweight sparse neural network

    CN121190950A

  • Industrial model fine tuning and reasoning method and device and electronic equipment

    CN121920544A