Efficient optimization selection and model adaptation method and system based on LoRA and MoE technologies

By building a wide range of LoRA module pools and efficient optimization selection methods for LoRA and MoE technologies, the problem of incomplete coverage of LoRA modules is solved, and the rapid adaptation of downstream tasks in small or zero-sample scenarios is achieved to improve model performance and adaptability.

CN120493993APending Publication Date: 2025-08-15ZHEJIANG UNIV OF TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510375496.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The problem of the incomplete coverage of LoRA modules in the existing technology in the case of few samples or zero samples has led to high demand for computing resources and it is difficult to quickly adapt to vertical field tasks.

Method used

Build a LoRA module pool covering a wide range of fields, efficient optimization selection and model adaptation through LoRA and MoE technology, including batch generation of LoRA modules, coarse and fine-grained selection, dynamic selection of LoRA modules, filtering using downstream task description, hidden layer features and confusion, and dynamically combining the model through the MoE architecture.

Benefits of technology

Quickly adapt to downstream tasks in scenarios with few samples or zero samples, significantly improve model performance, reduce computing power requirements, and improve model adaptability and flexibility in proprietary fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120493993A_ABST
    Figure CN120493993A_ABST
Patent Text Reader

Abstract

The invention discloses an efficient optimization selection and model adaptation method and system based on LoRA and MoE technologies, and the method comprises the steps: firstly, constructing a LoRA module pool for various models and vertical field data sets according to different field models and data set features, so as to rapidly screen and call adaptation models in similar tasks; secondly, based on downstream task description, hidden layer features and confusion, performing coarse-grained LoRA selection from a LoRA module pool; and then, by using the performance characteristics and the single LoRA weight distance, further screening a fine-grained LoRA module from the LoRA modules selected from the coarse-grained LoRA modules based on diversity. And finally, activating the selected LoRA module by adopting a Top-k strategy based on the MoE architecture, and finally determining the LoRA module which is most adaptive to the downstream task in combination with performance feedback after integration with the basic model. According to the method, a large number of LoRA modules can be effectively constructed, the module most adaptive to the downstream task is selected, and the accuracy of the model in processing tasks such as mathematical reasoning is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of efficient fine-tuning of large language models, and more specifically to a method and system for enhancing model performance in scenarios with few or zero samples. Background Art

[0002] In recent years, large language models (hereinafter referred to as "large models"), represented by ChatGPT, have made significant progress in the field of natural language processing. These models demonstrate strong language understanding and content generation capabilities, and excel in various language processing tasks such as translation, conversation, information extraction, and sentiment recognition, showing broad application prospects in general fields. However, despite the continuous improvement in the capabilities of general models, they still have significant shortcomings when solving problems in specialized and vertical domains. To improve the performance of domain-specific models, existing technologies have proposed methods for fine-tuning models, including full-parameter fine-tuning and parameter-efficient fine-tuning (PEFT). While full-parameter fine-tuning can significantly improve model performance, it requires a large amount of computational resources, limiting its application in resource-constrained scenarios. To this end, low-rank adaptation (LoRA) has been proposed as a parameter-efficient fine-tuning method that can improve model performance in downstream tasks while significantly reducing computational resources. Furthermore, with the popularity of open-source platforms (such as HuggingFace), users can easily upload and share fine-tuned LoRA modules, providing a fast solution for similar downstream tasks.

[0003] However, existing PEFT methods still face the challenge of high computational resource requirements in few-shot or zero-shot scenarios. Furthermore, current open-source platforms do not cover all domains, resulting in a lack of LoRA modules in certain verticals. Therefore, a solution is urgently needed to build a LoRA module pool that covers a wider range of domains. This module pool should include LoRA modules based on different model architectures and fine-tuned for diverse datasets, providing a rich selection for different tasks.

[0004] Based on this module pool, in few-shot learning scenarios, an efficient screening and combination mechanism can be used to quickly adapt to the application requirements of the target domain. Specifically, only a description of the downstream task is required to accurately select the appropriate LoRA module from the module pool through various LoRA selection methods, including the Mixture of Experts (MoE) mechanism. This process dynamically integrates the advantages of multiple LoRA modules, effectively improving the model's performance on unknown vertical domain tasks. Summary of the Invention

[0005] The present invention aims to overcome the above-mentioned problems of the prior art and provide an efficient optimization selection and model adaptation method and system based on LoRA and MoE technologies.

[0006] The present invention solves the problem of incomplete coverage of LoRA modules in existing online open source platforms, and makes full use of LoRA modules covering different fields to achieve rapid adaptation of downstream tasks in scenarios with few or zero samples, thereby reducing computing power requirements and improving the performance of the model in proprietary fields. The present invention proposes an efficient optimization selection and model adaptation method and system based on LoRA and MoE technologies.

[0007] The first aspect of the present invention relates to an efficient optimization selection and model adaptation method based on LoRA and MoE technology, comprising the following steps:

[0008] S1. Based on large model fine-tuning, select the basic model according to the downstream task type, batch generate LoRA modules and aggregate them into a LoRA module pool;

[0009] S2. Select LoRA modules from the LoRA module pool based on the coarse-grained downstream task;

[0010] S3. Implement fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture. Combine the selected LoRA modules with the base model obtained in step S1. Select the most suitable LoRA module by evaluating the performance of the combined model, and generate a final high-performance model to adapt to downstream task requirements.

[0011] Further preferably, the stated step S1 specifically includes:

[0012] Step 1.1: Collect a large number of different open-source models and evaluate their performance in different fields to determine the downstream task types that each model is more suitable for.

[0013] Step 1.2: Collect a large number of datasets from different fields, covering a wide range of areas, including medical question answering, mathematical reasoning, legal common sense, and general knowledge.

[0014] Step 1.3: Convert each dataset to Alpaca format to ensure data consistency and processability.

[0015] Step 1.4: Perform LoRA fine-tuning on the selected models and datasets converted to Alpaca format to generate LoRA modules for different models and vertical field datasets, and integrate these modules into a large LoRA module pool to quickly screen and call adapted LoRA modules in similar tasks.

[0016] Further preferably, the stated step S2 specifically includes:

[0017] Step 2.1: When receiving a new downstream task, obtain the specific description of the task and construct a small number of specific cases of the downstream task based on the description.

[0018] Step 2.2: Perform preliminary screening based on task descriptions. First, use ChatGPT's unified prompts to generate detailed, multi-faceted descriptions for each candidate dataset in the LoRA module pool. These descriptions are embedded in a vector space. ChatGPT is then used to generate the same description for the downstream task. Similarity is calculated in the vector space to select the M LoRA modules that are most similar to the downstream task description. The task description is used as the first feature for coarse-grained LoRA module selection.

[0019] Step 2.3: Filter based on hidden layer features. First, using the selected model, extract features for each layer on the candidate dataset and downstream task examples, including cosine similarity, Euclidean distance, and Manhattan distance. Calculate the average of the features of the first, middle, and last layers to obtain the similarity of the hidden layer features. This allows us to select the M LoRa modules that are closest to the downstream task. The hidden layer data is used as the second feature for selecting the coarse-grained LoRA modules.

[0020] Step 2.4: Screen based on perplexity (PPL) values. First, combine the selected models with candidate LoRA modules to generate fine-tuned models suitable for different domains. Then, use these models to perform PPL testing on downstream task cases to select the M LoRA modules with the lowest PPL values. Perplexity is used as the third feature for selecting coarse-grained LoRA modules.

[0021] Step 2.5: Combining the above three features (dataset description, hidden layer features and perplexity), we finally select M LoRAs as the result of coarse-grained LoRA module selection through weighted summation to adapt to downstream task requirements.

[0022] Further preferably, the stated step S3 specifically includes:

[0023] Step 3.1: The model is used to compare the generated responses on the coarse-grained filtered LoRA module dataset. And the underlying true answer y, using matching post-processing and accuracy post-processing operations with the true answer y, the formatted answer is extracted from the response, that is, This performance feature can directly reflect the model's ability to solve the problem and is used as the first feature selected by the fine-grained LoRA module.

[0024] The selected LoRA modules are grouped through permutation and combination, sorted in descending order according to the distance between individual LoRA weights, and this is used as the second feature for fine-grained LoRA module selection. Finally, these two features are weighted and summed, and the top N (N < M) LoRAs are selected as the result of fine-grained LoRA module selection for the purpose of diversity.

[0025] Step 3.2: Based on the fine-grained selection of LoRA modules, the hidden layer features of the downstream task are input into the Gating Network to generate the weight scores of each LoRA expert module. Specifically, the contribution degree of each LoRA expert module in a specific task is calculated through the gating network, and the top K (K < M) LoRA experts with the highest weights are selected according to the Top-K strategy. Subsequently, the outputs of these K experts are weighted and summed according to their weights to obtain the incremental parameters of the final model.

[0026] To prevent the gating network from relying too much on a few LoRA experts, a minimum activation frequency threshold for experts is further set, and an entropy maximization term for the expert weight distribution is added to the loss function. This mechanism aims to promote a more balanced use of experts, prevent the model from over-relying on a few experts, and thus improve the overall robustness and generalization ability of the model.

[0027] Step 3.3: For the activated K LoRA modules, the parameter increments are weighted according to the weights assigned by the gating network, and these weighted parameter increments are dynamically superimposed on the base model selected in the first part. During this process, performance feedback is obtained through real-time detection systems to continuously monitor the output quality during the downstream task inference process. The monitoring metrics include the perplexity of the generated results and the human evaluation score.

[0028] During the downstream task inference process, if the performance does not reach the threshold, weight reallocation is triggered: recalculate the similarity and adjust the combination of activated LoRA modules.

[0029] Step 3.4: Based on the evaluation results of the contribution of each LoRA expert module and the status of the LoRA module pool, the K LoRA modules are dynamically updated. Specifically, the average activation frequency of each LoRA module on the validation set is calculated to quantify its actual contribution in the current task environment. Based on this, LoRA modules with long-term low activation frequencies, deemed inefficient, or no longer suitable for the current task distribution are identified and marked. These marked inefficient LoRA modules are then removed from the LoRA module pool to maintain the efficiency and timeliness of the module pool. Simultaneously, new LoRA modules are selected from the results of the coarse-grained screening to supplement the LoRA module pool, ensuring the diversity and coverage of the LoRA modules in the module pool. These new modules undergo preliminary verification to ensure their effectiveness and adaptability. Furthermore, in response to changes in the task distribution, an automated fine-tuning process is triggered to generate additional LoRA modules and add them to the module pool. This maintains the diversity and timeliness of the module pool, ensuring that the model can quickly respond to changing task requirements and continuously optimize performance.

[0030] A second aspect of the present invention relates to a system for implementing the efficient optimization selection and model adaptation method based on LoRA and MoE technology of the present invention, comprising:

[0031] LoRA module pool building module, coarse-grained LoRA adaptation module, fine-grained adaptation and dynamic selection of LoRA modules based on MoE architecture;

[0032] The LoRA module pool construction module performs LoRA training based on models and data sets of different scopes and fields, and is used to construct a large number of LoRA modules;

[0033] The coarse-grained LoRA adaptation module makes a comprehensive selection based on the downstream task description, hidden layer features and perplexity for coarse-grained LoRA selection;

[0034] The fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture first improves the diversity within the group while maintaining the similarity outside the group based on performance characteristics and single LoRA weight distance; then uses the MoE architecture to evaluate the most suitable LoRA module through the performance after combining with the basic model, and generates a final high-performance model to adapt to downstream task requirements.

[0035] The present invention forms a wide-coverage LoRA module pool by training a large number of LoRAs in different fields, and proposes coarse-grained and fine-grained LoRA module selection methods, using the MoE architecture to dynamically combine models, thereby quickly adapting to downstream tasks and enhancing model performance in few-sample learning scenarios. The main innovations of the present invention are as follows:

[0036] (1) The present invention solves the problem of incomplete coverage of LoRA modules on current online open source platforms by constructing a LoRA module pool. We have collected a large number of open source models and datasets covering a wide range of fields, and uniformly processed these datasets into the Alpaca format, and then fine-tuned them for LoRA to generate LoRA modules for different models and vertical field datasets. This method not only effectively alleviates the limitations of open source platforms in terms of LoRA module coverage, but also provides strong support for basic research and applications, especially in scenarios with few or zero samples, which can quickly adapt to downstream tasks and significantly improve the flexibility and adaptability of the model.

[0037] (2) The present invention selects coarse-grained LoRA modules and can further screen out the most suitable LoRA modules only through the description of downstream tasks. Specifically, we use the similarity between the downstream task description and the description of the candidate LoRA module (calculated using Euclidean distance), hidden layer features, and perplexity as evaluation indicators, and perform weighted summation of these indicators to screen out the most suitable coarse-grained LoRA module. This method not only simplifies the selection process of the LoRA module, but also ensures that the selected module has high adaptability and performance in specific downstream tasks.

[0038] (3) The present invention enhances diversity through fine-grained LoRA module selection, and dynamically selects the most suitable LoRA module based on the mixture of experts (MoE) architecture and effectively combines it with the basic model. Specifically, based on the coarse-grained selected LoRA module, the performance characteristics and the single LoRA weight distance are further used to increase the diversity of the LoRA module as the fine-grained selection LoRA result. These features not only improve the selection accuracy of the module, but also enhance its adaptability to different tasks. At the same time, the hidden layer features are input into the gated network to generate the weights of each LoRA expert, and the performance feedback after the LoRA module with the highest weight is selected and combined with the basic model to ensure that the selected LoRA module can adapt to the specific downstream tasks to the greatest extent.

[0039] The advantages of the present invention are: it not only builds a LoRA module pool with wide coverage, but also dynamically adapts to downstream tasks and enhances model performance in few-sample learning scenarios, and has significant innovation and practicality in model adaptability and efficiency; the present invention can effectively construct a large number of LoRA modules and select the modules that are most suitable for downstream tasks, significantly improving the accuracy of the model when processing tasks such as mathematical reasoning. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings are used to provide an intuitive description of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention.

[0041] Figure 1 It is a schematic diagram of the system flow of the present invention;

[0042] Figure 2a-2d This is the coarse-grained selection LoRA result diagram of Example 1. Figure 2a is a numerical diagram of the hidden layer cosine similarity. Figure 2b is a diagram of the Euclidean distance of the hidden layer. Figure 2c is a schematic diagram of the hidden layer Manhattan distance, Figure 2d This is a numerical diagram of the PPL of the fine-tuned model on downstream task examples.

[0043] Figure 3 This is a comparison chart of the accuracy of the basic model in Example 1 and the LoRA after efficient optimization selection on the GSM8K dataset. DETAILED DESCRIPTION

[0044] The following examples are used to illustrate the present invention in more detail, and the technical methods and advantages of the present invention are described together with the examples of the present invention. The specific examples described herein are only used to illustrate the present invention and do not constitute a limitation of the present invention.

[0045] Example 1

[0046] This embodiment relates to a network education improvement method using the efficient optimization selection and model adaptation method based on LoRA and MoE technologies of the present invention, the steps of which include:

[0047] Step S1: Based on the fine-tuning of the large model, the basic model is selected according to the downstream task type, and LoRA modules are generated in batches and assembled into a LoRA module pool. The specific steps are:

[0048] Step 1.1: In online education contexts, especially when lacking direct instruction, students often feel lost when navigating complex problems, particularly in subjects like mathematics. Therefore, this example uses the GSM8K mathematics dataset as a case study data source for unknown downstream tasks. This aims to validate the effectiveness of the proposed method in improving online education data teaching capabilities and to perform accuracy calculations and analysis based on this dataset. Considering the dataset type and the expressiveness of the model, Llama3.2-1B-Instruct was selected as the base model.

[0049] Step 1.2: Retrieve forty open-source datasets in diverse fields, including commonsense reasoning, sentiment analysis, legal question answering, and medical knowledge. Representative datasets include: HellaSwag (a dataset for natural language reasoning tasks, focusing on contextual reasoning and commonsense reasoning), GSM8K (a benchmark for mathematical reasoning tasks), MATH (used to evaluate models on more complex mathematical tasks), Commonsense_QA (a dataset for commonsense question answering, suitable for evaluating models' ability to understand and answer commonsense-based questions), and COPA (a dataset for causal reasoning tasks, suitable for evaluating models' ability to understand causal relationships and perform causal reasoning). These datasets cover a wide range of fields, from commonsense reasoning to complex data problems, and can comprehensively evaluate the performance of models on different tasks.

[0050] Step 1.3: Convert all selected datasets to the Alpaca format to ensure data consistency and processability.

[0051] Step 1.4: Perform unified LoRA fine-tuning on the selected models and datasets converted to Alpaca format to generate LoRA modules for different models and vertical field datasets, and integrate these modules into a large LoRA module pool to quickly screen and call adapted LoRA modules in similar tasks.

[0052] S2. Select LoRA modules from the LoRA module pool based on the coarse-grained mathematical reasoning task. The specific steps are as follows:

[0053] Step 2.1: ChatGPT uses a unified prompt word to generate a unified task description for the GSM8K mathematical reasoning task dataset, specifically: Question-answering, English, Education, Mathematics, Open-ended Answers. This description covers the key features of the GSM8K dataset, such as question answering, education, and mathematics.

[0054] Step 2.2: Perform preliminary screening based on task descriptions. Generate comprehensive, detailed descriptions for each candidate dataset in the LoRA module pool using ChatGPT's unified prompts. These descriptions are embedded in a vector space and compared with the task descriptions generated in Step 2.1. The five LoRA modules that most closely match the mathematical reasoning descriptions are selected. The task descriptions serve as the first feature for coarse-grained LoRA module selection.

[0055] Step 2.3: Screening based on hidden layer features. Test the GSM8K dataset and the candidate dataset on the Llama3.2-1B-Instruct model, and calculate the cosine similarity, Euclidean distance, and Manhattan distance of different layers to obtain the hidden layer features. Cosine similarity is shown as follows: Figure 2a As shown. The Euclidean distance is shown as Figure 2b As shown. Manhattan distance is shown as Figure 2c As shown in Figure 2, the five LoRA modules with the closest similarity values to the GSM8K dataset are selected after weighted summation. The hidden layer data is used as the second feature for selecting the coarse-grained LoRA module.

[0056] Step 2.4: Combine the candidate LoRA modules with Llama3.2-1B-Instruct to generate all fine-tuned models, and perform perplexity tests on the GSM8K dataset to finally select the 5 LoRA modules with the best PPL values. The PPL values are shown as follows: Figure 2d As shown in Figure 2, perplexity is used as the third feature selected by the coarse-grained LoRA module.

[0057] Step 2.5: Combining the above three features (dataset description, hidden layer features and perplexity), the five optimal coarse-grained LoRA modules are finally determined through weighted summation.

[0058] S3. Implement fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture. Combine the selected LoRA modules with Llama3.2-1B-Instruct. Evaluate the performance of the combined model to select the most suitable LoRA module and generate a high-performance model to meet downstream task requirements. The specific steps are as follows:

[0059] Step 3.1: Based on the coarse-grained LoRA modules similar to the GSM8K dataset, the model-generated responses are compared with the ground truth answers on the datasets of these modules, and the formatted answers are extracted and used as the first feature selected by the fine-grained LoRA module. At the same time, the screened LoRA modules are permuted, grouped, and sorted in descending order based on the distance between individual LoRA weights, which is used as the second feature selected by the fine-grained LoRA module.

[0060] A weighted sum of these two features—response accuracy and LoRA weighted distance—is used to comprehensively evaluate the performance of each candidate module. Based on this combined score, the top four LoRA modules are selected. This approach not only maintains the similarity criterion established in the coarse-grained phase, which selects the dataset most relevant to the mathematical reasoning task, but also ensures that the candidate modules are selected to maximize diversity within the group.

[0061] Step 3.2: Construct a single-layer MLP gated network with the input dimension being the hidden layer features of the last layer of CLS tokens in Llama3.2-1B-Instruct (dimension 1024). The output dimension corresponds to the four candidate LoRA modules. The network weights are initialized using the Xavier normal distribution, the bias term is set to zero, and a Top-2 or Top-3 activation strategy is used to balance computational efficiency and performance.

[0062] Step 3.3: For the activated top-2 or top-3 LoRA modules, weight their parameter increments according to the weights of the gating network, and dynamically add these weighted parameter increments to the Llama3.2-1B-Instruct model.

[0063] Step 3.4: Obtain perplexity feedback through a real-time detection system to continuously monitor the output quality during the mathematical reasoning task. Based on this feedback, the LoRA module with the best performance and the best fit for the GSM8K dataset is ultimately determined.

[0064] Finally, after selecting coarse-grained and fine-grained LoRA modules and expert activation of the MoE architecture, the accuracy of this embodiment was improved from 28.19% to 32.23%, significantly improving the performance of the model in mathematical reasoning, such as Figure 3 As shown in the figure, this improvement effectively improves the overall performance of mathematical reasoning tasks and further provides enhanced teaching capabilities for online education platforms.

[0065] S4. The model is used in online education to optimize mathematics tutoring capabilities.

[0066] The online education platform dynamically combines the optimal LoRA module with the original basic model through a selection method from the LoRA module pool. The enhanced model constructed significantly improves the mathematics teaching ability of online education and further supports students' needs for mathematics tutoring.

[0067] Example 2

[0068] This embodiment provides a system for implementing the efficient optimization selection and model adaptation method based on LoRA and MoE technology of embodiment 1, including:

[0069] LoRA module pool building module, coarse-grained LoRA adaptation module, fine-grained adaptation and dynamic selection of LoRA modules based on MoE architecture;

[0070] The LoRA module pool construction module performs LoRA training based on models and data sets of different scopes and fields, and is used to construct a large number of LoRA modules;

[0071] The coarse-grained LoRA adaptation module makes a comprehensive selection based on the downstream task description, hidden layer features and perplexity for coarse-grained LoRA selection;

[0072] The fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture first improves the diversity within the group while maintaining the similarity outside the group based on performance characteristics and single LoRA weight distance; then uses the MoE architecture to evaluate the most suitable LoRA module through the performance after combining with the basic model, and generates a final high-performance model to adapt to downstream task requirements.

[0073] The above descriptions are merely embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the ideas and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. An efficient optimization selection and model adaptation method based on LoRA and MoE technology, characterized by: The steps include: S1. Based on large model fine-tuning, select the basic model according to the downstream task type, batch generate LoRA modules and aggregate them into a LoRA module pool; S2. Select LoRA modules from the LoRA module pool based on the coarse-grained downstream task; S3. Implement fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture. Combine the selected LoRA modules with the base model obtained in step S1. Select the most suitable LoRA module by evaluating the performance of the combined model, and generate a final high-performance model to adapt to downstream task requirements.

2. The efficient optimization selection and model adaptation method based on LoRA and MoE technology as claimed in claim 1, characterized in that Step S1 includes the following steps: Step 1.1: Collect a large number of different open-source models and evaluate their performance in different fields to determine the downstream tasks for which each model is most suitable. Step 1.2: Collect a large number of datasets from different fields, covering a wide range of areas, including medical question answering, mathematical reasoning, legal common sense, and general knowledge; Step 1.3: Convert each dataset to Alpaca format to ensure data consistency and processability. Step 1.4: Perform LoRA fine-tuning on the selected models and datasets converted to Alpaca format to generate LoRA modules for different models and vertical field datasets, and integrate these modules into a large LoRA module pool to quickly screen and call adapted LoRA modules in similar tasks.

3. The efficient optimization selection and model adaptation method based on LoRA and MoE technology as claimed in claim 1, characterized in that Step S2 includes the following steps: Step 2.1: When a new downstream task is received, obtain the specific description of the task and generate a specific case of the downstream task based on the description; Step 2.2: Perform preliminary screening based on the task description. First, use ChatGPT's unified prompt words to generate a multi-faceted detailed description for each candidate dataset in the LoRA module pool. Embed these descriptions into the vector space, and simultaneously use ChatGPT to generate the same description for the downstream task. Calculate the similarity in the vector space and select the M LoRA modules that are closest to the downstream task description. Use the task description as the first feature for selecting the coarse-grained LoRA module. Step 2.3: Screening based on hidden layer features. First, using the selected model, extract the features of each layer on the candidate dataset and downstream task cases, including cosine similarity, Euclidean distance, and Manhattan distance. Calculate the average of the features of the first, middle, and last layers to obtain the similarity of the hidden layer features, and screen out the M LoRa modules that are closest to the downstream task. Use the hidden layer data as the second feature for selecting the coarse-grained LoRa module. Step 2.4: Screen based on perplexity PPL values. First, combine the selected models with candidate LoRA modules to generate fine-tuned models suitable for different fields. Then use these models to perform PPL detection on downstream task cases to screen out the M LoRA modules with the lowest PPL values. Use perplexity as the third feature for selecting coarse-grained LoRA modules. Step 2.5: Integrate the first feature, the second feature, and the third feature, and finally select M LoRAs through weighted summation as the result of the coarse-grained LoRA module selection to adapt to the downstream task requirements.

4. The efficient optimization selection and model adaptation method based on LoRA and MoE technology as claimed in claim 1, characterized in that Step S3 includes the following steps: Step 3.1: The model is used to compare the generated responses on the coarse-grained filtered LoRA module dataset. And the underlying true answer y, using matching post-processing and accuracy post-processing operations with the true answer y, extract the formatted answer from the response, that is, This performance feature can directly reflect the model's ability to solve problems and is used as the first feature selected by the fine-grained LoRA module; Arrange and combine the selected LoRA modules into groups, sort them in descending order according to the single LoRA weight distance, and use this as the second feature for the fine-grained LoRA module selection; finally, perform weighted summation on these two features and select the top N LoRAs, where N < M, as the result of the fine-grained selection of LoRA modules for the purpose of diversity. Step 3.2: Based on the fine-grained selection of LoRA modules, input the hidden layer features of the downstream task into the gating network Gating Network to generate the weight scores of each LoRA expert module; specifically, calculate the contribution degree of each LoRA expert module in a specific task through the gating network, and select the top K LoRA experts with the highest weights according to the Top-K strategy, where K < M; then, sum the outputs of these K experts weighted by their weights to obtain the incremental parameters of the final model. To avoid the gating network being overly dependent on a few LoRA experts, an expert minimum activation frequency threshold is further set, and an entropy maximization term for the expert weight distribution is added to the loss function; this mechanism aims to promote a more balanced use of experts, prevent the model from relying too much on a few experts, and thus improve the robustness and generalization ability of the overall model. Step 3.3: For the activated K LoRA modules, weight the parameter increments according to the weights assigned by the gating network, and dynamically superimpose these weighted parameter increments onto the base model selected in the first part; during this process, obtain performance feedback through a real-time detection system to continuously monitor the output quality during the downstream task inference process; the monitoring metrics include the perplexity of the generated results and the human evaluation score. During the downstream task inference process, if the performance does not reach the threshold, trigger weight reallocation: recalculate the similarity and adjust the combination of activated LoRA modules. Step 3.4: Based on the evaluation results of the contribution of each LoRA expert module and the status of the LoRA module pool, the K LoRA modules are dynamically updated. Specifically, the average activation frequency of each LoRA module on the validation set is first counted to quantify its actual contribution in the current task environment, and based on this, those LoRA modules that have been in a low activation frequency state for a long time and are considered inefficient or no longer suitable for the current task distribution are identified and marked. Subsequently, these LoRA modules marked as inefficient are removed from the LoRA module pool to maintain the efficiency and timeliness of the module pool. At the same time, new LoRA modules are selected from the results of coarse-grained screening to supplement the LoRA module pool to ensure the diversity and coverage of the LoRA modules in the module pool. The selected new modules must undergo preliminary verification to ensure their effectiveness and adaptability. In addition, in response to changes in task distribution, an automated fine-tuning process is triggered to generate supplementary LoRA modules and add them to the module pool, thereby maintaining the diversity and timeliness of the module pool and ensuring that the model can quickly respond to different task requirements and continuously optimize performance.

5. A system for implementing the efficient optimization selection and model adaptation method based on LoRA and MoE technology according to any one of claims 1 to 4, characterized in that: include: LoRA module pool building module, coarse-grained LoRA adaptation module, fine-grained adaptation and dynamic selection of LoRA modules based on MoE architecture; The LoRA module pool construction module performs LoRA training based on models and data sets of different scopes and fields, and is used to construct a large number of LoRA modules; The coarse-grained LoRA adaptation module makes a comprehensive selection based on the downstream task description, hidden layer features and perplexity for coarse-grained LoRA selection; The fine-grained adaptation and dynamic selection of LoRA modules based on the MoE architecture first improves the diversity within the group while maintaining the similarity outside the group based on performance characteristics and single LoRA weight distance; then uses the MoE architecture to evaluate the most suitable LoRA module through the performance after combining with the basic model, and generates a final high-performance model to adapt to downstream task requirements.

Citation Information

Cited By

  • Dynamic routing parameter efficient fine tuning method and system based on LoRA-MoE

    CN121480595A

  • LoRA-moe-based dynamic routing parameter efficient fine-tuning method and system

    CN121480595B