Automatic large model fusion processing method, device, storage medium and electronic device
Through the CMAES model, the weight of the basic model is automatically calculated, and the problem of model fusion relies on intuition and domain knowledge in the existing technology is solved, multi-task and cross-domain model fusion is realized, and the universality and practicality of model fusion is improved.
Patent Information
- Application Number
- CN202411088910.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-08-09
AI Technical Summary
Existing model fusion technologies rely on human intuition and domain knowledge, making it difficult to fully explore all possible model combinations, limiting the potential of model fusion and limited optimization space.
The covariance matrix adaptive evolution strategy (CMAES) model is used to automatically calculate the weight of the basic model, and the algorithm parameters are updated iteratively, the fusion parameters are optimized to form the final fusion model.
Reduce dependence on human intuition and domain knowledge, explore innovative fusion solutions, handle multiple tasks and cross-domain model fusion, enhance the versatility, practicality and comprehensiveness of model fusion, and reduce costs.
Smart Images

Figure CN118656646B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence and machine learning, and in particular to an automated large-model fusion processing method, device, storage medium, and electronic device. Background Art
[0002] Currently, model fusion, as an emerging trend, has shown great potential in the development of large language models (LLMs). Model fusion technology improves performance and reduces the risk of overfitting by combining multiple large models as base models into a more powerful fusion model. In the process of model fusion, it is necessary to determine the weight of the fused base model in the formed fusion model.
[0003] One of the existing methods is disclosed in patent CN117436029A, which usually adopts weighted average prediction results of multiple models to obtain more accurate predictions. This process is highly dependent on the intuitive judgment of model developers on model selection and fusion strategy, and usually requires in-depth understanding of the target domain. Given the diversity of open source models and evaluation benchmarks, traditional manual fusion methods are difficult to fully explore all possible combinations, limiting their development potential.
[0004] Another approach is to use a hybrid expert model (MoE), as disclosed in patent CN117669652A. MoE is an integrated learning strategy that dynamically selects a set of basic models that best suit the current input for processing through a series of gating mechanisms (usually based on input features). Each expert model focuses on a different subspace or task feature of the data, and the final output is the weighted sum of the outputs of all activated expert models. However, the MoE approach still has limitations in model fusion, which limits the potential of model fusion, and there is still room for optimization in model fusion. Summary of the invention
[0005] The purpose of the present application is to provide an automated large model fusion processing method, device, storage medium and electronic device to solve at least one of the above-mentioned problems.
[0006] In a first aspect, the present application provides an automated large model fusion processing method, the method comprising:
[0007] Obtaining initial fusion parameters of each basic model and a covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters, wherein the initial fusion parameters include an initial weight of each basic model;
[0008] Calculating an initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set;
[0009] Iteratively updating the algorithm parameters in the CMAES model based on the latest fitness value to form fusion parameters under the current iteration, wherein the algorithm parameters include one or more of a covariance matrix, a population, and a mean vector;
[0010] Calculate the fitness value of the fusion model to be optimized for the training set, which is generated based on the basic model and the fusion parameters in the current iteration, wherein the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fitness value used in the first iteration update is the initial fitness value;
[0011] Return to repeatedly execute the iterative update of the algorithm parameters in the CMAES model based on the latest fitness value until the iteration termination condition is met;
[0012] When the iteration termination condition is met, the final fusion parameters of the basic model are determined according to the fitness value in each iteration, and the final fusion model is formed according to the final fusion parameters and the basic model.
[0013] In one embodiment, the method further comprises:
[0014] Prepare a training set and multiple basic models for model fusion, wherein the training set contains training samples of various task types;
[0015] Calling the basic model to execute the training sample to obtain an execution result, and calculating an execution performance vector of the basic model for the training set according to the execution result;
[0016] Performing task relevance analysis on the training samples to form a relevance matrix for quantifying similarities and / or complementarities between the tasks;
[0017] The initial fusion parameter is generated according to the correlation matrix and / or the execution performance vector.
[0018] In one of the embodiments, the iterative updating of the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration includes: iterative updating of the algorithm parameters in the CMAES model based on the correlation matrix and / or the execution performance vector and the latest fitness value to form the fusion parameters under the current iteration.
[0019] In one of the embodiments, the algorithm parameters in the CMAES model are iteratively updated based on the correlation matrix and / or the execution performance vector and the latest fitness value to form fusion parameters under the current iteration, including: running the CMAES model based on the latest fitness value, and outputting the fusion parameters to be optimized; adjusting the fusion parameters to be optimized based on the correlation matrix and / or the execution performance vector, and using the adjusted fusion parameters as the fusion parameters under the current iteration.
[0020] In one of the embodiments, the algorithm parameters in the CMAES model are iteratively updated based on the latest fitness value to form the fusion parameters under the current iteration, including: running the CMAES model based on the latest fitness value and outputting the fusion parameters to be optimized; calculating the first difference between the latest fusion parameters and one or more historical fusion parameters; calculating the second difference between the latest fitness value and one or more historical fitness values; adjusting the fusion parameters to be optimized based on the first difference and the second difference, and using the adjusted fusion parameters as the fusion parameters under the current iteration, the latest fusion parameters are the fusion parameters generated in the last iteration, the historical fusion parameters are the fusion parameters generated before the latest fusion parameters are generated, and the historical fitness values are the fitness values generated before the latest fitness values.
[0021] In one of the embodiments, the adjusting the fusion parameters to be optimized based on the first difference and the second difference includes: identifying the weight parameters to be adjusted in the fusion parameters according to the first difference and the second difference; when the first difference exceeds a first threshold and the second difference corresponding to the first difference is less than the second threshold, increasing the value of the weight parameter; when the first difference is less than a third threshold and the second difference corresponding to the first difference is greater than a fourth threshold, increasing the value of the weight parameter, and the first threshold is greater than the third threshold.
[0022] In one of the embodiments, the method also includes: obtaining task information of the task to be executed; determining the task type to which the task to be executed belongs based on the task information; querying the basic model to be called and the final weight that match the task type from the final fusion parameters; executing the task to be executed based on the fusion model formed by the basic model to be called and the final weight, and outputting the task execution result.
[0023] In a second aspect of the present application, an automated large model fusion processing device is provided, the device comprising:
[0024] An initial data acquisition module, used to acquire initial fusion parameters of each basic model and a covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters, wherein the initial fusion parameters include initial weights of each basic model;
[0025] A model iteration module, used to calculate the initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set; iteratively update the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration, and the algorithm parameters include one or more of the covariance matrix, the population and the mean vector; calculate the fitness value of the fusion model to be optimized generated based on the basic model and the fusion parameters under the current iteration for the training set, wherein the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fitness value used in the first iterative update is the initial fitness value; return to repeatedly execute the iterative update of the algorithm parameters in the CMAES model based on the latest fitness value until the iteration termination condition is met;
[0026] The fusion model generation module is used to determine the final fusion parameters of the basic model according to the fitness value in each iteration when the iteration termination condition is met, and form a final fusion model according to the final fusion parameters and the basic model.
[0027] In a third aspect of the present application, a computer-readable storage medium is provided, on which executable instructions are stored. When the executable instructions are executed by a processor, the processor executes the method described in any embodiment of the present application.
[0028] In a fourth aspect of the present application, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the method described in any embodiment of the present application.
[0029] The automated large-model fusion processing method, device, storage medium, and electronic device in this application can reduce the reliance on human intuition and domain knowledge by setting up a CMAES model and using the CMAES model to automatically calculate the weights of the basic models used in the fusion model, and can explore innovative fusion solutions that are difficult to design manually. And because the optimal fusion model is found through model automation, it is not limited to specific fields recognized by humans, and can handle the fusion of multiple tasks and cross-domain models, generate models with broader practical application value, and enhance the versatility, practicality, and comprehensiveness of model fusion.
[0030] Compared with the prior art, the beneficial effects of this application include:
[0031] 1. This application adopts automated model fusion, rather than simple weighted average, to automatically discover model combination strategies, reduce reliance on human intuition and domain knowledge, and explore innovative fusion solutions that are difficult to design manually.
[0032] 2. Wide applicability: This application can handle model fusion of multiple tasks and cross-domains, generate models with broader practical application value, and enhance the versatility and practicality of model fusion.
[0033] 3. Reduce costs: This application does not require a large amount of additional data or computing resources for retraining, and is more cost-effective than traditional model development.
[0034] 4. Multi-objective optimization: This application provides a new basic model development paradigm, promotes the research of efficient model building methods, can simultaneously integrate multiple optimization objectives, and further improve the comprehensiveness of model performance through multi-objective genetic algorithms. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope of the present application.
[0036] Figure 1 A schematic diagram of a process flow of an automated large model fusion processing method in one embodiment;
[0037] Figure 2 A schematic diagram of a process for iteratively updating algorithm parameters in a CMAES model based on the latest fitness value in one embodiment;
[0038] Figure 3 A schematic diagram of a process of executing a task using a fusion model in one embodiment;
[0039] Figure 4 It is a structural block diagram of an automatic large model fusion processing device in one embodiment;
[0040] Figure 5 It is a structural block diagram of an automatic large model fusion processing device in another embodiment;
[0041] Figure 6 It is a structural block diagram of an automatic large model fusion processing device in another embodiment;
[0042] Figure 7 FIG. 4 is a structural block diagram of an electronic device in an embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] All terms (including technical and scientific terms) used in this application have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used here should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0045] For example, the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first difference may be referred to as a second difference, and similarly, a second difference may be referred to as a first difference. Both the first difference and the second difference are differences, but they are not the same difference.
[0046] For another example, the terms “include”, “comprising”, etc. used in this application indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0047] In one embodiment, Figure 1 As shown, an automated large model fusion processing method is provided, the method comprising:
[0048] Step 102, obtaining the initial fusion parameters of each basic model and the covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters.
[0049] In this embodiment, the initial fusion parameter is a fusion parameter constructed for input into the CMAES (Covariance Matrix Adaptation Evolution Strategy, covariance matrix adaptive evolution strategy) model and optimized. In addition to the dimension of the weight of the relevant basic model, the fusion parameter also includes one or more dimensions of the sparsification parameter, learning rate, regularization coefficient, etc. corresponding to the basic model. Through the CMAES model, the specific values of one or more parameters in the fusion parameter can be optimized to output the final fusion parameter. Among them, the weight represents the mixing ratio of the corresponding basic model in the fusion model. The higher the weight, the greater the influence of the corresponding basic model on the fusion model. The sparsification parameter can reflect the complexity of the fusion model. In some cases, it is expected that the parameters of some basic models in the model fusion process are sparse, that is, some parameters are set to zero or close to zero values to reduce the complexity of the model. Through sparsification, the model can reduce unnecessary computing resource consumption and reduce the redundancy of the model while maintaining high performance.
[0050] The initial fusion parameters can be pre-set appropriate values. For example, in the initial fusion parameters, the initial values (such as weight values) of each parameter (such as weight parameter) are all set to 0.5, indicating that at the beginning, the contributions of each basic model are roughly balanced. Furthermore, the initial parameter value can also be set based on expert experience or the execution performance of the relevant basic model for different task types, so that the initial fusion parameters set at the beginning are closer to the optimal fusion parameters, thereby improving the efficiency of subsequent iterative optimization of fusion parameters.
[0051] In this embodiment, the constructed CMAES model is an evolutionary strategy algorithm model, which guides the search process by adaptively adjusting the search direction and step size, optimizes the relevant algorithm parameters, and gradually approaches the optimal parameter configuration to obtain the optimized fusion parameters, which has the advantages of high efficiency and global convergence.
[0052] The relevant algorithm parameters in the model include one or more of the covariance matrix, population and mean vector. Among them, the mean vector and covariance matrix are used to describe the current optimal position and its distribution characteristics in the search space. Based on the mean vector, the optimized fusion parameters can be reflected.
[0053] The fusion parameters can be represented as corresponding three-dimensional space matrices. For example, a three-dimensional space matrix X of M×N×K. M represents the number of basic models, N represents the number of types of tasks to be performed, and K represents the number of dimensions of the parameters. The element x(m,n,k) in the matrix X represents the parameter of the kth dimension of the corresponding mth basic model for the nth type of task. The parameter in the kth dimension can be one of the weights, sparsification parameters, etc. represented above.
[0054] For example, when there is only one task type, there are three basic models, namely basic model A, basic model B and basic model C. The corresponding fusion parameters include two dimensions: weight parameter and sparsification parameter. The elements representing the weight parameters of the three basic models are w A 、w B 、w C , the elements representing its sparsification parameters are s A 、s B and C , then the formed fusion parameter can be expressed as (w A ,w B ,w C ,s A ,s B ,s C ).
[0055] The basic model is a large model that participates in model fusion in advance, including one or more of a general large model, a domain-specific large model, and a multimodal large model. For example, the general large model may include the GPT series model, the BERT model, etc. The domain-specific large model may include the Transformer model in the field of computer vision and the XLNet model in the field of natural language processing. The multimodal large model includes the CLIP model and the DALL-E model, etc.
[0056] The task types of the execution tasks may include text classification, sentiment analysis, math problem solving, image recognition, and other types, or subdivided types under these types. The electronic device pre-prepares a variety of basic models and a training set consisting of a plurality of execution tasks as training samples, and each training sample corresponds to a task type.
[0057] The electronic device can fuse multiple basic models so that the formed fusion model can obtain better processing results than any single basic model when performing task processing.
[0058] Step 104, calculating the initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set.
[0059] The fitness value is used to reflect the accuracy of the relevant model in executing the task. The fitness value can be represented by one or more parameters that can reflect the accuracy, such as the zero-shot accuracy. For example, the calculated zero-shot accuracy can be directly used as the corresponding fitness value.
[0060] For example, the set training set contains 1069 training samples. An initial fusion model is formed according to the set initial fusion parameters and the basic model. The initial fusion model is used to execute the training samples. Based on the execution results of the fusion model and the standard results corresponding to the training samples, the zero-shot accuracy of the initial fusion model is calculated, and the zero-shot accuracy is directly used as the initial fitness value.
[0061] Optionally, the electronic device applies the formed initial fusion parameters to the model fusion task, calculates the zero-shot accuracy corresponding to the training set using the fusion model formed according to the initial fusion parameters, and uses the zero-shot accuracy as the initial fitness value.
[0062] Step 106, iteratively update the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters in the current iteration.
[0063] In this embodiment, the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fusion parameter is the fusion parameter generated in the previous iteration. It can be understood that the latest fusion parameter and the latest fitness value will be updated according to the occurrence of the iteration. And relative to the latest fusion parameter and the latest fitness value, the fusion parameter generated by the iteration before the latest fusion parameter is the historical fusion parameter, and the fitness value generated by the iteration before the latest fitness value is the historical fitness value.
[0064] The fitness value used in the current iteration is the latest fitness value, and the latest fitness value used in the first iteration update is the initial fitness value.
[0065] Specifically, in the CMAES model, the size of the set population can be determined according to the number of parameters of the fusion parameters to be optimized, for example, the size of the population can be calculated according to 4+(3ln(nparams), where nparams represents the number of parameters to be optimized. After the size of the population is determined, an initial population can be generated according to a multivariate Gaussian distribution. The initial scale in the covariance matrix is set by a step size parameter, for example, the step size parameter can be set to 1 / 6. Based on the set relevant parameters, the CMAES model is run, and the covariance matrix C(g) and the mean vector m(g) and one or more of the populations can be adaptively updated, so that the search distribution gradually concentrates on the area of the better solution. Based on the updated covariance matrix and mean vector, the corresponding fusion parameter solution can be output, and the fusion parameter solution can be reflected by the mean vector.
[0066] Exemplarily, part of the implementation code of the parameter optimization of the CMAES algorithm in model fusion is as follows:
[0067] import numpy as np
[0068] def initialize_params(nparams, sigma):
[0069] x_mean = np.full(nparams, 0.5)# The initial parameter value is set to 0.5
[0070] C = sigma ** 2 * np.eye(nparams)# Initial covariance matrix
[0071] lambda_ = 4 + int(3 * np.log(nparams)) # population size
[0072] pc = np.zeros(nparams)# Cumulative evolution path
[0073] ps = np.zeros(nparams) # Scalar of cumulative evolutionary path
[0074] return x_mean, C, lambda_, pc, ps
[0075] def sample_population(x_mean, C, lambda_):
[0076] return np.random.multivariate_normal(x_mean, C, lambda_)
[0077] def evaluate_fitness(population):
[0078] fitness = np.array([evaluate_individual(x) for x in population])
[0079] return fitness
[0080] def update_parameters(x_mean, C, fitness, pc, ps, lambda_):
[0081] # Select the best individual
[0082] sorted_indices = np.argsort(-fitness)
[0083] fitness = fitness[sorted_indices]
[0084] population = population[sorted_indices]
[0085] # Update the mean vector
[0086] mu = 1 / (lambda_ / 2 + 1) * sum((1 / fitness[i]) * population[i]fori in range(lambda_ / / 2))
[0087] x_mean = (1 - cs) * x_mean + cs * mu
[0088] # Update the covariance matrix
[0089] C = (1 - cc) * C + cc * np.dot(population[:lambda_ / / 2] - x_mean,(population[:lambda_ / / 2]- x_mean).T)
[0090] # Update evolution path
[0091] pc = (1 - cs / (lambda_ * (2 - cs))) * pc + cs * (x_mean - pc)
[0092] ps = (1 - cs / (lambda_ * (2 - cs))) * ps + (cs / (np.sqrt(2 * (1 -cc) * cc))) * (x_mean - pc)
[0093] return x_mean, C, pc, ps
[0094] def cma_es_optimize(nparams, iterations, sigma):
[0095] x_mean, C, lambda_, pc, ps = initialize_params(nparams, sigma)
[0096] for iteration in range(iterations):
[0097] population = sample_population(x_mean, C, lambda_)
[0098] fitness = evaluate_fitness(population)
[0099] x_mean, C, pc, ps = update_parameters(x_mean, C, fitness, pc, ps,lambda_)
[0100] if iteration % 100 == 0: # Output information every 100 iterations
[0101] print(f"Iteration {iteration}: Best Fitness = {np.max(fitness)}")
[0102] if np.max(fitness)>= threshold:# Assume there is a preset fitness threshold
[0103] break
[0104] best_individual = population[np.argmax(fitness)]
[0105] return best_individual
[0106] def evaluate_individual(x):
[0107] # Apply parameter x to the model fusion task
[0108] # Calculate fitness values, such as zero-shot pass@1 accuracy
[0109] # Here we need to define a specific fitness function based on the actual task
[0110] pass
[0111] # Parameter settings
[0112] nparams = 10 # number of parameters
[0113] iterations = 1000# Iterations
[0114] sigma = 1 / 6# The size of the initial covariance matrix
[0115] threshold = 0.95# fitness threshold
[0116] # Run the CMA-ES algorithm
[0117] best_parameters = cma_es_optimize(nparams, iterations, sigma)
[0118] print("Optimal parameters:", best_parameters)
[0119] Step 108, calculating the fitness value of the fusion model to be optimized generated based on the basic model and the latest fusion parameters for the training set.
[0120] In this embodiment, similar to step 104, for each output fusion parameter, a corresponding fusion model is formed, and the formed fusion model is used to execute the corresponding training sample, and the corresponding fitness value is calculated based on the execution result of the fusion model and the standard result corresponding to the training sample. The higher the fitness value, the higher the accuracy of the fusion model formed based on the corresponding fusion parameter in executing the task, that is, the better the formed fusion model.
[0121] Optionally, the corresponding weight parameter value is extracted from the generated fusion parameter, so that the weight value of each basic model in the fusion model can be determined, and the corresponding fusion model to be optimized is formed based on the weight parameter and the basic model. The fusion model to be optimized can be the weighted sum of the basic model and the corresponding weight value.
[0122] Step 110, check whether the iteration termination condition is met. If yes, return to step 106, otherwise, execute step 112.
[0123] In this embodiment, step 106 and step 108 can be executed in a loop to achieve iterative optimization of the fusion parameters. After each output of the optimized fusion parameters, it can be detected whether the output fusion parameters meet the iteration termination condition. When the iteration termination condition is met, the iteration is terminated and step 112 is executed. Otherwise, the iteration continues until the iteration termination condition is met.
[0124] Specifically, the iteration termination condition may include one or more combinations of the following conditions: 1) the number of iterations reaches a preset iteration number threshold, 2) the fitness value formed by the iterations has converged; 3) the latest fitness value reaches a preset fitness threshold.
[0125] The iteration number threshold may be a pre-set appropriate number, such as 1000, and the fitness threshold may be a set appropriate threshold. When the threshold is reached, it indicates that the generated fusion parameter solution is sufficient to meet the accuracy requirements of task execution.
[0126] Furthermore, after the fusion model to be optimized is formed, the fusion model is further tested on the validation set until the test result of the formed fusion model on the validation set meets the iteration termination condition. The iteration termination condition is that the accuracy of the test result for the validation set exceeds a preset accuracy threshold, otherwise, continue to return to step 106. Similar to the training set, the validation set also includes verification task samples of various task types.
[0127] Step 112, determining the final fusion parameters of the basic model according to the corresponding fitness value in each iteration, and forming a final fusion model according to the final fusion parameters and the basic model.
[0128] In this embodiment, after the iteration is completed, the final fusion parameter can be determined based on the fusion parameter output by each iteration, and the final fusion parameter is used to represent the fusion parameter used when the final fusion model is formed. Optionally, the final fusion parameter can be one of the fusion parameters output by each iteration, such as the fusion parameter with the highest corresponding fitness value among the fusion parameters output by each iteration, or the fusion parameter with the highest execution efficiency for the fusion model among the candidate fusion parameters whose fitness reaches the fitness threshold. Among them, the execution efficiency is related to the specific basic model selected, and also to the number of basic models selected. The electronic device can select the fusion parameter with the least basic model used from all the fusion parameters that meet the fitness requirements as the final fusion parameter, thereby improving the execution efficiency of the fusion model.
[0129] For example, the corresponding weight parameter of the fusion parameter with the highest fitness value can be selected, and a fusion model can be formed based on the selected weight parameter and the basic model. The fusion model can be a weighted sum of the corresponding weight value and the basic model.
[0130] Among them, in the fusion parameters, when the value of the parameter representing the weight of a certain basic model is 0, it means that the basic model does not participate in the fusion of the corresponding execution task. The execution efficiency of the fusion model is negatively correlated with the number of basic models fused. The more basic models fused, the lower the execution efficiency. The calculated fusion parameters can reflect the number of basic models that need to be fused. By selecting the fusion parameters that meet the fitness requirements and have the highest execution efficiency as the final fusion parameters, the fusion model ensures the execution efficiency of the fusion model while taking into account the requirements of task execution accuracy.
[0131] The automated large model fusion processing method in this application can reduce the reliance on human intuition and domain knowledge by setting up a CMAES model and using the CMAES model to automatically calculate the weights of the basic models used in the fusion model, and can explore innovative fusion solutions that are difficult to design manually. And because the optimal fusion model is found through model automation, it is not limited to specific fields recognized by humans, and can handle the fusion of multiple tasks and cross-domain models, generate models with broader practical application value, and enhance the versatility, practicality and comprehensiveness of model fusion.
[0132] In one embodiment, before step 102, the method further includes: preparing multiple basic models and training sets for model fusion, wherein the training sets include training samples of various task types; calling the basic models to execute the training samples to obtain execution results, and calculating the execution performance vector of the basic model for the training set according to the execution results; performing task correlation analysis on the training samples to form a correlation matrix for quantifying the similarity and / or complementarity between tasks.
[0133] In this embodiment, the basic model may include a variety of models such as the above-mentioned GPT series model, BERT model, Transformer model, XLNet model, CLIP model and DALL-E model. The training set is a set of training samples prepared in advance for optimizing the fusion parameters through the CMAES model. Each training sample is an execution task corresponding to a task type. Each training sample is also provided with a standard result corresponding to the corresponding execution task. In the training set, the number of training samples of each task type is multiple, so that there are enough training samples to optimize the fusion parameters. According to the possible application field of the model (i.e., the corresponding task type), a group of representative tasks can be carefully selected as the corresponding training samples, and the selected representative tasks can cover all task types that the model may involve, such as text classification, sentiment analysis, mathematical problem solving, image recognition, etc.
[0134] In this embodiment, after preparing the basic model and the training set, a performance evaluation can be performed on each basic model to obtain the execution performance of each model for various task types. Based on the obtained execution performance, the advantages and disadvantages of each basic model for various task types can be known. For example, the execution accuracy and efficiency of the relevant basic models for various types of tasks can be obtained.
[0135] Specifically, corresponding performance evaluation indicators may be set, and the evaluation indicators may include one or more of accuracy, recall rate, F1 score, average precision, etc. For the execution result obtained for a certain basic model for a corresponding training sample, the corresponding performance evaluation indicator may be determined according to the execution result and the corresponding standard result, and then the corresponding execution performance may be calculated according to the performance evaluation indicator, and the execution performance may be converted into a corresponding execution performance vector. Each element in the execution performance vector represents the execution performance evaluation indicator score obtained by executing a corresponding training sample for the corresponding basic model.
[0136] For example, the performance vector formed by a base model for five training samples is [0.92, 0.85, 0.97, 0.89, 0.94].
[0137] The index score may be a normalized score, so that the execution performance vector corresponding to each basic model is not affected by the difficulty of the execution task. The normalization method used may be a combination of one or more normalization methods such as z-score normalization or min-max scaling. The higher the score, the better the corresponding execution performance.
[0138] By comparing the normalized vectors of each model, we can intuitively identify which types of tasks each model performs best on. For example, if a model scores higher than other models on all text understanding tasks, it can be considered to have an advantage in natural language processing.
[0139] The task correlation matrix is a matrix used to quantify the similarity or complementarity between different tasks. The numerical values of the elements in the matrix can reflect the magnitude of the correlation or complementarity between the corresponding multiple tasks. The correlation matrix is used to analyze and understand the intrinsic connection between different tasks, such as whether they may share certain underlying features or knowledge. Specifically, cosine similarity or correlation coefficient can be used to quantify the correlation between tasks. These methods can provide a numerical similarity or complementarity score for each task pair, and obtain the corresponding correlation matrix based on the score, thereby providing data support for the formulation of model fusion strategies.
[0140] The similarity between tasks refers to the similarity of the methods or features used by different tasks when processing data or solving problems. For example, text classification and sentiment analysis may both require a deep understanding of the text content, so they may have a high similarity score in the task relevance matrix.
[0141] Complementarity between tasks: refers to the fact that different tasks may need complementary features or information to solve problems. For example, image recognition may require the assistance of object detection, and object detection may rely on certain features of image recognition.
[0142] Based on the correlation matrix that reflects the similarity and / or complementarity of tasks, it is possible to identify the similarities and / or complementarities between types of tasks. Then, the model fusion and resource allocation optimization can be guided based on the identification results. For example, the fusion parameters output during the CMAES model training process can be optimized and adjusted based on the identification results to improve the iteration efficiency of the model.
[0143] For example, it is possible to identify which tasks’ base models can be fused to improve overall performance. For example, if two tasks show high correlation in the matrix, their corresponding base models may have more shared or complementary parameters. During the model fusion process, the task correlation matrix can help identify and reduce redundant parameters or features, thereby improving the efficiency and performance of the model.
[0144] For optimizing resource allocation, understanding the similarities and complementarities between tasks can help developers allocate training resources more effectively. For example, for highly related tasks, more training data or model parameters may be shared.
[0145] This correlation matrix can also improve the model's generalization ability and promote innovative model design. By identifying and utilizing the similarities and complementarities between tasks, models that can better generalize to unseen tasks can be designed. By deeply understanding the correlation between tasks, developers can design new model architectures or fusion strategies that may not have been considered in traditional model design.
[0146] In one embodiment, before step 102, the method further includes: generating initial fusion parameters according to the correlation matrix and / or the execution performance vector.
[0147] In this embodiment, since the correlation matrix can reflect the similarity or complementary relationship between each basic model for each type of task, and the execution performance vector can directly reflect the execution performance of the corresponding basic task for each training sample, the initial fusion parameters can be constructed based on one or more of the correlation matrix and the execution performance vector, so that the constructed initial fusion parameters can be closer to the final fusion parameters, thereby improving the iteration efficiency of the subsequent CMAES model, so that the final fusion parameters can be obtained more quickly, or the obtained final fusion parameters can be better.
[0148] Specifically, the value of the weight dimension in the initial fusion parameter can be set according to the execution performance vector so that the parameter value of the set weight dimension is positively correlated with the execution performance, for example, the corresponding execution performance can be directly used as the parameter value of the corresponding weight dimension. The sparsification parameter in the fusion parameter can be set according to the correlation matrix, for example, in the fusion parameter space, the value of the parameter representing the sparsification dimension is negatively correlated or positively correlated with the corresponding value in the correlation matrix.
[0149] In one embodiment, for basic models that perform well on highly related tasks, you can consider directly fusing their parameters, such as setting a relatively high weight for them; while for complementary tasks, you can maximize the advantages of each basic model by designing a specific fusion layer or weight allocation rule.
[0150] In one embodiment, step 106 includes: iteratively updating algorithm parameters in the CMAES model based on the correlation matrix and / or the execution performance vector and the latest fitness value to form fusion parameters in the current iteration.
[0151] In this embodiment, since the performance manifestation or impact of each basic model on each type of computing task is identified through the correlation matrix and the execution performance vector, the correlation matrix and / or the execution performance vector can be used to update the fusion parameters output by the CMAES model during the iteration process, so that the fusion parameters can approach the optimal fusion parameters more quickly.
[0152] Specifically, based on the performance manifestation or influence of each basic model on each type of computing task preliminarily identified according to the correlation matrix and the execution performance vector, the generated fusion parameters can be actively intervened or adjusted so that the adjusted fusion parameters are closer to the optimal fusion parameters.
[0153] The performance manifestation or influence of the basic model on various types of computing tasks may include one or more of the sensitivity, accuracy, conflict and complementarity of the computing tasks, and the corresponding sensitivity, accuracy, conflict and complementarity can be quantified through relevant values, such as the corresponding sensitivity, accuracy, conflict and complementarity can be calculated. The meaning of these performance manifestations or influence information and the guiding principles for adjusting the fusion parameters are as follows.
[0154] Sensitivity is used to indicate the impact on the execution result of the fusion model when the weight of the corresponding basic model in the fusion model changes. That is, when executing a task of a certain type, the corresponding basic model in the fusion model changes its weight, which affects the execution result of the task of this type. The greater the sensitivity, the greater the impact; the smaller the sensitivity, the smaller the impact. For basic models with lower sensitivity, it means that their existence in the fusion model is less significant, and the corresponding fusion parameter value can be set to a smaller value, such as setting its weight to a smaller value or even to 0; and for basic models with higher sensitivity, the corresponding fusion parameter representing the basic model can be amplified. By amplifying the fusion parameter, such as amplifying its weight, the parameter changes that reflect the new capabilities obtained after fine-tuning the fusion model can be strengthened, ensuring that these key differences can be retained and strengthened in the fusion model.
[0155] Conflict means parameter sign conflict, that is, for a fusion parameter with opposite signs (which is common in different training contexts), they are adjusted to be consistent to avoid positive and negative offset effects and reduce conflicts that may be caused by direct parameter superposition. Complementarity means that there are some parameters with similar or complementary corresponding functions in the basic model. For complementary parameters, they can be merged and aligned, that is, only those parameters with similar or complementary corresponding functions in different models are merged, and those irrelevant or potentially interfering parameters are ignored.
[0156] In one embodiment, the CMAES model is run based on the latest fitness value to output the fusion parameters to be optimized; the fusion parameters to be optimized are adjusted based on the correlation matrix and / or the execution performance vector, and the adjusted fusion parameters are used as the fusion parameters in the current iteration.
[0157] After the electronic device has identified the performance manifestation or impact information, it adjusts one or more elements that reflect the relevant performance manifestation or impact in the output fusion parameters of the CMAES model based on the above-mentioned adjustment principles, and uses the adjusted fusion parameters as the fusion parameters of the current iteration, so that the new fusion parameters generated in each iteration can approach the optimal fusion parameters more quickly, thereby improving the iteration efficiency.
[0158] The fusion parameters of each iteration output of the CMAES model can be adjusted, and the fusion parameters output under some iterations can also be adjusted, for example, the fusion parameters of the iteration output are adjusted once every d times. d can be any suitable integer value.
[0159] In one embodiment, Figure 2 As shown, the algorithm parameters in the CMAES model are iteratively updated based on the latest fitness value, including:
[0160] Step 202: Run the CMAES model based on the latest fitness value and output the fusion parameters to be optimized.
[0161] Step 204: Calculate a first difference between the latest fusion parameter and one or more historical fusion parameters.
[0162] Step 206: Calculate a second difference between the latest fitness value and one or more historical fitness values.
[0163] Step 208: adjusting the fusion parameters to be optimized based on the first difference and the second difference, and using the adjusted fusion parameters as the fusion parameters in the current iteration.
[0164] In this embodiment, the execution order between step 202 and step 206 is not limited. For example, they can be executed in parallel, or step 202 can be executed first, and then step 204 and step 206 can be executed separately.
[0165] The latest fusion parameter is the fusion parameter generated in the last iteration, the historical fusion parameter is the fusion parameter generated before the latest fusion parameter is generated, and the historical fitness value is the fitness value generated before the latest fitness value.
[0166] For the fusion model and fitness value outputted in each iteration, the difference between the currently generated fusion model and the historical fusion model relative to the fusion model (recorded as the first difference) can be calculated, and the difference between the currently generated fitness value and the historical fitness value (recorded as the second difference) can be calculated. Based on the two differences, it is determined whether the relevant parameters in the current fusion model need to be adjusted.
[0167] The first difference degree represents the difference between the current fusion model and multiple historical fusion models, and the difference degree can be the difference between the two, or a numerical value such as a difference percentage; similarly, the second difference degree also represents the difference between the current fitness value and the historical fitness value, and the difference degree can also be the difference between the two, or a numerical value such as a difference percentage.
[0168] Among them, through the first difference and the second difference, one or more of the sensitivity, accuracy, conflict and complementarity of the weight change of the corresponding basic model to the fusion model can be determined, and based on this, the elements corresponding to the specific parameters in the fusion model are adjusted. Among them, the specific parameter is a parameter in the fusion parameter that reflects the above-mentioned performance embodiment or influence type, for example, the specific parameter can be a weight parameter.
[0169] For example, the mean vector obtained at the kth iteration (when the mean vector needs to be optimized, the mean vector represents the optimized mean vector) is the mean vector Y k , the obtained fusion parameter is X k , based on the mean vector Y k and fusion parameter X k The fusion model formed is the fusion model Z k , based on the model Z k The fitness value obtained by running the training set is the fitness value W k When the i-th iteration is completed and the i+1-th iteration is in progress (the i+1-th iteration has not yet been completed), the latest fitness value used in the iteration process is the fitness value W i , the latest fusion parameter used is the fusion parameter X iWhen the output fusion parameter needs to be optimized in the i+1th iteration, the generated fusion parameter to be optimized is X' i+1 , the optimized fusion parameter is X i+1 Then X1~X i-1 That is the historical fusion parameter, W1~W i-1 It is the historical fitness value.
[0170] Remember the latest fusion parameter X i Fusion parameter X with history j The first difference is X ij , the latest fitness value W i and the historical fitness value W j The second difference between ij , the first difference is X ij The second difference W ij There is a corresponding relationship between them, which reflects the change in the performance of the fusion model (i.e., the change in fitness value) when the corresponding fusion parameters in the fusion model change. Among them, i>j≥1.
[0171] Step 208 includes: adjusting the values of one or more elements in the fusion parameters to be optimized based on the first difference and a second difference corresponding to the first difference.
[0172] Among them, when the first difference X ij is relatively small, but its corresponding second difference W ij When it is relatively large, it means that when a certain element or elements in the fusion model (for example, the element corresponds to a certain or several basic models) undergo a slight change, it has a greater impact on the performance of the fusion model. At this time, the values of the corresponding elements in the fusion parameters to be optimized can be adjusted accordingly. For example, the values of the corresponding elements can be adjusted so that the weights of the corresponding basic models are increased, thereby further amplifying the influence of the basic model on the fusion model.
[0173] On the contrary, when the first difference X ij is relatively large, but its corresponding second difference W ij If it is relatively small, it means that when one or several elements in the fusion model (for example, the element corresponds to one or several basic models) undergo a large change, it has a small impact on the performance of the fusion model. At this time, the values of the one or several elements corresponding to the formed fusion parameters to be optimized can also be adjusted accordingly. For example, the values of the corresponding elements can be adjusted so that the weights reflected by them for the corresponding basic models are small or even 0, thereby avoiding the influence of the basic model on the fusion model.
[0174] In one embodiment, step 208 further includes: adjusting the fusion parameters to be optimized based on the first difference, the second difference, the correlation matrix and the execution performance vector.
[0175] In this embodiment, the performance manifestation or impact determined based on the first difference and the second difference is compared and verified with the performance manifestation or impact determined based on the correlation matrix and / or the execution performance vector. When the verification is consistent, the fusion parameter is adjusted.
[0176] The performance manifestation or impact identified based on the two differences is further checked for consistency with the impact reflected by the correlation matrix and the execution performance vector. Only when the two are consistent, the fusion parameters are adjusted. This can avoid misjudgment in the identification of performance manifestation or impact and improve the accuracy of fusion parameter adjustment.
[0177] In one embodiment, step 208 includes: identifying the weight parameter to be adjusted in the fusion parameter based on the first difference and the second difference; when the first difference exceeds the first threshold and the second difference corresponding to the first difference is less than the second threshold, increasing the value of the weight parameter; when the first difference is less than the third threshold and the second difference corresponding to the first difference is greater than the fourth threshold, increasing the value of the weight parameter.
[0178] In this embodiment, the electronic device pre-sets a first threshold, a second threshold, a third threshold, and a fourth threshold. The first threshold is a threshold used to measure whether the first difference is large enough, the third threshold is a threshold used to measure whether the first difference is small enough, the second threshold is a threshold used to measure whether the second difference is small enough on the basis that the first difference is large enough, and the fourth threshold is a threshold used to measure whether the second difference is large enough on the basis that the first difference is small enough. Among them, the specific values of the 4 thresholds can be set to appropriate values according to actual conditions, wherein the first threshold is greater than the third threshold, the second threshold can be greater than the fourth threshold, or can be less than or equal to the fourth threshold.
[0179] For example, there are three basic models, namely basic model A, basic model B and basic model C. Under a certain task type, the values of the weight parameters in the corresponding fusion parameters are w A 、w B 、w C .
[0180] When the first difference is calculated as X ij is greater than the first threshold, and the corresponding second difference W ijIf the difference is less than the second threshold, it can be analyzed which parameter in the fusion parameters causes the difference. For example, when it is identified that the main parameter causing the difference is w A When , it means that when the weight proportion in the basic model A changes greatly, the impact on the output result of the fusion model is very small, and the w A The parameter is used as the weight parameter to be adjusted. At this time, the corresponding w in the fusion parameter to be optimized can be further reduced. A The value of the parameter. For example, you can A The parameter is reduced by a basic value based on the obtained value, or multiplied by a coefficient less than 1 to obtain an adjusted value. When the adjusted value is less than 0, the value is directly set to 0.
[0181] When the first difference is calculated as X ij is less than the third threshold, and the corresponding second difference W ij is greater than the fourth threshold, analyzing which parameter in the fusion parameters causes the difference, for example, when it is identified that the main parameter causing the difference is w B When , it means that the weight of the corresponding basic model B has a slight change, which has a relatively large impact on the output result of the entire fusion model. B The parameter is used as the weight parameter to be adjusted. At this time, the corresponding w in the fusion parameter to be optimized can be further reduced. B The value of the parameter. For example, you can B The parameter increases a base value based on the obtained value, or multiplies it by a coefficient greater than 1 to obtain the adjusted value.
[0182] By adjusting the relevant parameters in the fusion model according to the difference, the formed fusion model can approach the optimal fusion parameters more quickly, thereby improving the model iteration efficiency.
[0183] In one embodiment, Figure 3 As shown, the above method also includes the step of using the fusion model to perform the task, which includes:
[0184] Step 302: Obtain task information of the task to be executed.
[0185] In this embodiment, the task to be executed represents a task that needs to be executed using a fusion model, and refers to a specific work unit that needs to be processed, analyzed, or generate results by the system or device. These tasks can be computing tasks, data processing tasks, machine learning reasoning tasks, natural language processing tasks, etc., depending on the needs of the application scenario. Task information may include input data related to the task, and may further include a task type identifier, execution conditions, etc. The input data represents the original data required to perform the task, such as text to be classified, images to be recognized, speech to be converted, and other data. The execution conditions represent additional conditions or constraints that need to be considered when performing the task, such as time constraints, resource constraints, specific processing requirements, etc. The task type identifier is used to identify the nature and category of the task, such as task types such as text classification, image recognition, and speech conversion.
[0186] For example, the task to be performed is a text classification task, and its task information includes the text data to be classified and the classification criteria. Or the task information of the task to be performed is to perform sentiment analysis on a piece of text, which belongs to the field of natural language processing, and judge whether it is positive, negative or neutral sentiment, or the task information of the task to be performed is to identify all faces in a picture and mark their positions and sizes.
[0187] In one embodiment, the task to be performed may be a comprehensive task that includes multiple task types, such as a resume screening task. The task specifically includes identifying the content of each resume provided and analyzing whether the content matches the recruitment requirements, and the content may also include image content. The task includes corresponding text processing, image recognition and other task types.
[0188] Step 304: Determine the task type of the task to be executed based on the task information.
[0189] In this embodiment, the electronic device can determine the task type suitable for classification based on the task information. For example, if the task information includes an identifier of "text classification", the system can determine that the task type is a text classification task.
[0190] For comprehensive tasks to be performed involving multiple task types, the electronic device can identify and disassemble the task to be performed to form multiple subtasks, so that each subtask corresponds to a task type. The corresponding input data is also disassembled into multiple subtask data, so that each subtask corresponds to corresponding sub-input data.
[0191] Step 306, query the basic model to be called and the final weight that matches the task type from the final fusion parameters.
[0192] In this embodiment, for the task type determined by the task to be executed, a weight matching the corresponding task type can be extracted from the obtained final fusion parameters and used as the final weight. The final fusion parameters are obtained in the previous automated large model fusion process, and include the final weights of each basic model under different task types.
[0193] Step 308: Execute the task to be executed based on the fusion model formed by the basic model to be called and the final weight, and output the task execution result.
[0194] For the final weight extracted, the basic model corresponding to the weight is obtained to form a fusion model for executing the task to be executed, and the formed fusion model is called to execute the task to be executed, and the corresponding task execution result is output. The result may be a classification label, a predicted value, a generated text, etc., depending on the nature and requirements of the task.
[0195] In the present application, through the generated fusion model, it is possible to use the fusion model to execute tasks of various task types, and the obtained execution results are better than the execution results of a single basic model.
[0196] In one embodiment, an automated large model fusion processing device is provided, such as Figure 4 As shown, the device comprises:
[0197] The initial data acquisition module 402 is used to obtain the initial fusion parameters of each basic model and the covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters. The initial fusion parameters include the initial weights of each basic model.
[0198] The model iteration module 404 is used to calculate the initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set; iteratively update the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration, and the algorithm parameters include one or more of the covariance matrix, the population and the mean vector; calculate the fitness value of the fusion model to be optimized generated based on the basic model and the fusion parameters under the current iteration for the training set, wherein the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fitness value used in the first iterative update is the initial fitness value; return to repeatedly execute the iterative update of the algorithm parameters in the CMAES model based on the latest fitness value until the iteration termination condition is met.
[0199] The fusion model generation module 406 is used to determine the final fusion parameters of the basic model according to the fitness value in each iteration when the iteration termination condition is met, and form a final fusion model according to the final fusion parameters and the basic model.
[0200] In one embodiment, Figure 5 As shown, the above device also includes:.
[0201] The initial data acquisition module 402 is also used to prepare a training set and a plurality of basic models for model fusion, wherein the training set includes training samples of various task types.
[0202] The performance analysis module 502 is used to call the basic model to execute the training samples, obtain the execution results, and calculate the execution performance vector of the basic model for the training set according to the execution results; perform task correlation analysis on the training samples to form a correlation matrix for quantifying the similarity and / or complementarity between tasks.
[0203] The initial fusion parameter generating module 504 is used to generate initial fusion parameters according to the correlation matrix and / or the execution performance vector.
[0204] In one embodiment, the model iteration module 404 is further used to iteratively update the algorithm parameters in the CMAES model based on the correlation matrix and / or the execution performance vector and the latest fitness value to form the fusion parameters in the current iteration.
[0205] In one embodiment, the model iteration module 404 is also used to run the CMAES model based on the latest fitness value and output the fusion parameters to be optimized; adjust the fusion parameters to be optimized based on the correlation matrix and / or the execution performance vector, and use the adjusted fusion parameters as the fusion parameters in the current iteration.
[0206] In one embodiment, the model iteration module 404 is also used to run the CMAES model based on the latest fitness value and output the fusion parameters to be optimized; calculate the first difference between the latest fusion parameters and one or more historical fusion parameters; calculate the second difference between the latest fitness value and one or more historical fitness values; adjust the fusion parameters to be optimized based on the first difference and the second difference, and use the adjusted fusion parameters as the fusion parameters under the current iteration, the latest fusion parameters are the fusion parameters generated in the last iteration, the historical fusion parameters are the fusion parameters generated before the latest fusion parameters are generated, and the historical fitness values are the fitness values generated before the latest fitness values.
[0207] In one embodiment, the model iteration module 404 is also used to identify the weight parameter to be adjusted in the fusion parameter based on the first difference and the second difference; when the first difference exceeds the first threshold and the second difference corresponding to the first difference is less than the second threshold, the value of the weight parameter is increased; when the first difference is less than the third threshold and the second difference corresponding to the first difference is greater than the fourth threshold, the value of the weight parameter is increased, and the first threshold is greater than the third threshold.
[0208] In one embodiment, Figure 6 As shown, the device also includes:
[0209] The task information acquisition module 602 is used to acquire the task information of the task to be executed.
[0210] The task execution module 604 is used to determine the task type to which the task to be executed belongs based on the task information; query the basic model to be called and the final weight that match the task type from the final fusion parameters; execute the task to be executed based on the fusion model formed by the basic model to be called and the final weight, and output the task execution result.
[0211] In one embodiment, a computer-readable storage medium is provided, on which executable instructions are stored. When the instructions are executed by a processor, the processor executes the steps in the above-mentioned method embodiments.
[0212] In one embodiment, an electronic device is also provided, including one or more processors; a memory, in which one or more programs are stored, wherein when the one or more programs are executed by one or more processors, the one or more processors execute the steps in the above-mentioned method embodiments.
[0213] In one embodiment, Figure 7 As shown, it shows a schematic diagram of the structure of an electronic device for implementing an embodiment of the present application. The electronic device 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0214] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0215] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, including a computer-readable medium carrying instructions, in such an embodiment, the instructions can be downloaded and installed from a network through a communication part 709, and / or installed from a removable medium 711. When the instructions are executed by a central processing unit (CPU) 701, the various method steps described in the present application are executed.
[0216] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0217] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the above claims, any one of the claimed embodiments may be used in any combination. The information disclosed in this background technology section is intended only to deepen the understanding of the overall background technology of the present application and should not be regarded as an admission or in any form of implication that the information constitutes prior art known to those skilled in the art.
Claims
1. An automated large model fusion processing method, characterized in that: The method comprises: Obtaining initial fusion parameters of each basic model and a covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters, wherein the initial fusion parameters include an initial weight of each basic model; Calculating an initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set; Iteratively updating the algorithm parameters in the CMAES model based on the latest fitness value to form fusion parameters under the current iteration, wherein the algorithm parameters include one or more of a covariance matrix, a population, and a mean vector; Calculate the fitness value of the fusion model to be optimized for the training set, which is generated based on the basic model and the fusion parameters in the current iteration, wherein the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fitness value used in the first iteration update is the initial fitness value; Return to repeatedly execute the iterative update of the algorithm parameters in the CMAES model based on the latest fitness value until the iteration termination condition is met; When the iteration termination condition is met, the final fusion parameters of the basic model are determined according to the fitness value in each iteration, and the final fusion model is formed according to the final fusion parameters and the basic model; Obtaining task information of tasks to be performed, wherein the tasks to be performed include one or more of computing tasks, data processing tasks, machine learning reasoning tasks, and natural language processing tasks; Determine the task type of the to-be-performed task based on the task information, where the task type includes one or more of text classification, image recognition, and speech conversion; Querying the basic model to be called and the final weight matching the task type from the final fusion parameters; The task to be executed is executed based on the fusion model formed by the basic model to be called and the final weight, and the task execution result is output.
2. The method according to claim 1, characterized in that The method further comprises: Prepare a training set and multiple basic models for model fusion, wherein the training set contains training samples of various task types; Calling the basic model to execute the training sample to obtain an execution result, and calculating an execution performance vector of the basic model for the training set according to the execution result; Performing task relevance analysis on the training samples to form a relevance matrix for quantifying similarities and / or complementarities between the tasks; The initial fusion parameter is generated according to the correlation matrix and / or the execution performance vector.
3. The method according to claim 2, characterized in that The iterative updating of the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration includes: iteratively updating the algorithm parameters in the CMAES model based on the correlation matrix and / or the execution performance vector and the latest fitness value to form the fusion parameters under the current iteration.
4. The method according to claim 3, characterized in that The iterative updating of the algorithm parameters in the CMAES model based on the correlation matrix and / or the execution performance vector and the latest fitness value to form the fusion parameters under the current iteration includes: Run the CMAES model based on the latest fitness value and output the fusion parameters to be optimized; The fusion parameters to be optimized are adjusted based on the correlation matrix and / or the execution performance vector, and the adjusted fusion parameters are used as fusion parameters in the current iteration.
5. The method according to claim 1, characterized in that The iterative updating of the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration includes: Run the CMAES model based on the latest fitness value and output the fusion parameters to be optimized; Calculating a first difference between the latest fusion parameter and one or more historical fusion parameters; Calculating a second difference between the latest fitness value and one or more historical fitness values; The fusion parameters to be optimized are adjusted based on the first difference and the second difference, and the adjusted fusion parameters are used as the fusion parameters in the current iteration, the latest fusion parameters are the fusion parameters generated in the last iteration, the historical fusion parameters are the fusion parameters generated before the latest fusion parameters are generated, and the historical fitness values are the fitness values generated before the latest fitness values.
6. The method according to claim 5, characterized in that The adjusting the fusion parameter to be optimized based on the first difference and the second difference includes: identifying a weight parameter to be adjusted in a fusion parameter according to the first difference and the second difference; When the first difference exceeds a first threshold and a second difference corresponding to the first difference is less than a second threshold, increasing the value of the weight parameter; When the first difference is smaller than a third threshold and a second difference corresponding to the first difference is larger than a fourth threshold, the value of the weight parameter is increased, and the first threshold is larger than the third threshold.
7. An automated large model fusion processing device, characterized in that: The device comprises: An initial data acquisition module, used to acquire initial fusion parameters of each basic model and a covariance matrix adaptive evolution strategy CMAES model for optimizing the fusion parameters, wherein the initial fusion parameters include initial weights of each basic model; A model iteration module, used to calculate the initial fitness value of the fusion model to be optimized formed based on the basic model and the initial fusion parameters for the training set; iteratively update the algorithm parameters in the CMAES model based on the latest fitness value to form the fusion parameters under the current iteration, and the algorithm parameters include one or more of the covariance matrix, the population and the mean vector; calculate the fitness value of the fusion model to be optimized generated based on the basic model and the fusion parameters under the current iteration for the training set, wherein the latest fitness value used in the current iteration is the fitness value generated in the previous iteration, and the latest fitness value used in the first iterative update is the initial fitness value; return to repeatedly execute the iterative update of the algorithm parameters in the CMAES model based on the latest fitness value until the iteration termination condition is met; A fusion model generation module is used to determine the final fusion parameters of the basic model according to the fitness value in each iteration when the iteration termination condition is met, and form a final fusion model according to the final fusion parameters and the basic model; A task information acquisition module, used to acquire task information of tasks to be performed, wherein the tasks to be performed include one or more of computing tasks, data processing tasks, machine learning reasoning tasks, and natural language processing tasks; A task execution module is used to determine the task type to which the task to be executed belongs based on the task information, query the basic model to be called and the final weight that match the task type from the final fusion parameters, execute the task to be executed based on the fusion model formed by the basic model to be called and the final weight, and output the task execution result, wherein the task type includes one or more of text classification, image recognition, and speech conversion.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores executable instructions, and when the executable instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 6.
9. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, causes the one or more processors to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method and system for serial collaborative fusion of multiple large models
CN117436029A
Processing method and device for hybrid expert model
CN117669652A
Hyper-parameter optimization method based on adaptive model
CN110110862A
Cmaes clustering optimization method based on covariance matrix eigenvalue curve similarity
CN110516756A
Cluster federated learning method and device fusing parameter optimization
CN116362329A
