A training method and device for a hybrid expert model based on decision tree
Through decision tree router and backpropagation technology, the problem of uneven expert distribution in mixed expert model training is solved, balanced distribution of sub-expert models is achieved, overfitting and resource waste are avoided, and the efficiency of the model is improved.
Patent Information
- Application Number
- CN202410271303.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-03-11
AI Technical Summary
Existing mixed expert models have the problem of uneven expert distribution during training, leading to overfitting and resource waste.
A hybrid expert model training method based on decision trees is used to allocate the data set to leaf nodes through the decision tree router, and establish the association of sub-expert models based on the number of leaf nodes. The decision tree router parameters are updated through backpropagation to realize sub-experts. Equilibrium distribution of models.
It effectively avoids overfitting and resource waste, achieves balanced distribution of sub-expert models, and improves the parameter efficiency and calculation efficiency of the model.
Smart Images

Figure CN118114754B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of neural network, and in particular relates to a training method and device for a hybrid expert model based on a decision tree. Background Art
[0002] The hybrid expert model is a deep learning architecture that improves the parameter efficiency and computational efficiency of the overall model by distributing input data to multiple expert models. The core idea is to decompose a large model into a set of expert sub-models with fewer parameters and more efficient computation, and coordinate the work of these experts through a gating network.
[0003] During training, existing hybrid expert models usually pass data to each expert model and the gating network. The gating network generates a set of weights representing the degree of activation of each expert model. Each expert model then generates a corresponding output, which is then weighted and summed with the weights generated by the gating network to obtain the final output. However, when the routing strategy of the gating network cannot satisfy more experts, there is an imbalanced distribution of experts, resulting in overfitting, waste of resources and other phenomena. Summary of the invention
[0004] In view of the above analysis, the embodiments of the present invention aim to provide a training method and device for a hybrid expert model based on a decision tree, so as to solve one or more of the above problems existing in the prior art.
[0005] The object of the present invention is achieved in that:
[0006] The first aspect of the present invention provides a training method for a hybrid expert model based on a decision tree, comprising:
[0007] Get the data set to be trained;
[0008] Inputting the data set to be trained into a decision tree router for classification, so as to distribute the data set to be trained to leaf nodes of the decision tree;
[0009] According to the leaf nodes, determining the number of sub-expert models in the hybrid expert model, and establishing an association relationship between the leaf nodes and the sub-expert models;
[0010] According to the association relationship, the data in each leaf node is input into the corresponding sub-expert model for training;
[0011] Back propagation training is performed based on the training results of the sub-expert models to update the parameters of the decision tree router to obtain the hybrid expert model.
[0012] Furthermore, before the data set to be trained is input into the decision tree router, the data set to be trained is preprocessed, and the preprocessing includes data cleaning, normalization and outlier removal.
[0013] Furthermore, the step of inputting the data set to be trained into a decision tree router for classification includes: the decision tree router includes a plurality of decision trees with a depth of 1; the decision tree with a depth of 1 distributes the input data set to two nodes of the decision tree through Gini impurity; if the Gini impurity of a node of the decision tree is greater than a preset threshold, the data set in the node is input into a decision tree with a depth of 1 in the next layer for further classification; until the Gini impurity of a node of the decision tree is less than the preset threshold, the node at this time is set as a leaf node.
[0014] Further, each of the decision trees has an allocation criterion as shown below, and the allocation criterion is used to balance the size of the data set allocated to the nodes of the decision tree;
[0015] abs(|{f(g n )>0}|-|{f(g n )≤0}|)
[0016] Among them, g n represents the gradient of the nth data sample with respect to the mixed expert model, f(g n ) represents mapping gn to a real number, |{·}| represents the size of the set, and abs(·) represents the absolute value.
[0017] Furthermore, the establishing of the association relationship between the leaf node and the sub-expert model includes: matching one of the sub-expert models for each leaf node by training a reinforcement learning model, specifically including: constructing an environment to simulate the matching process between the leaf node and the sub-expert model; setting an action space and a reward signal; obtaining a matching strategy based on the characteristics of the leaf node and the action space; and training the reinforcement learning model based on the result of the matching strategy and the reward signal to obtain the optimal matching strategy.
[0018] Furthermore, the establishing of the association relationship between the leaf node and the sub-expert model also includes: searching for the association relationship between the leaf node and the sub-expert model through an optimization search algorithm, specifically including: constructing a search space to represent all possible association relationships between the leaf node and the sub-expert model; defining a fitness function to evaluate the quality of each association relationship; and searching for the optimal association relationship in the search space according to the fitness function through the optimization search algorithm.
[0019] Furthermore, it also includes adjusting the parameters of the hybrid expert model through cross-validation, specifically including: dividing the data set to be trained into K subsets; using each of the subsets as a validation set and the remaining K-1 subsets as training sets; training the hybrid expert model on the training set and evaluating the performance of the hybrid expert model on the validation set; calculating the average performance of the hybrid expert model after K training times; and adjusting the parameters of the hybrid expert model according to the average performance to obtain the optimal model.
[0020] Furthermore, it also includes adjusting the parameters of the hybrid expert model through back propagation to minimize the loss function of the hybrid expert model.
[0021] Furthermore, it also includes adjusting the parameters of the sub-expert model in real time according to the characteristics of the input data set when using the hybrid expert model.
[0022] The second aspect of the present invention provides a training device for a hybrid expert model based on a decision tree, comprising:
[0023] An acquisition module is used to obtain the data set to be trained;
[0024] An allocation module, used for inputting the data set to be trained into a decision tree router for classification, so as to allocate the data set to be trained to the leaf nodes of the decision tree;
[0025] An association module, used to determine the number of sub-expert models in the hybrid expert model according to the leaf node, and establish an association relationship between the leaf node and the sub-expert model;
[0026] A training module is used to input the data in each leaf node into the corresponding sub-expert model for training according to the association relationship; and perform back propagation training based on the training results of the sub-expert model to update the parameters of the decision tree router to obtain the hybrid expert model.
[0027] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0028] The training method of the hybrid expert model based on decision tree provided by the present invention distributes the data set to leaf nodes through a decision tree router provided with a decision tree algorithm, and trains the data in each leaf node respectively through sub-expert models with the same number as the leaf nodes, thereby achieving balanced distribution of sub-expert models and avoiding problems such as overfitting and waste of resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this specification. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0030] Figure 1 A flowchart of a training method for a hybrid expert model based on a decision tree provided in Example 1 of the present invention;
[0031] Figure 2 A schematic diagram of a training device for a hybrid expert model based on a decision tree provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. It should be noted that, in the absence of conflict, the embodiments and features in the embodiments disclosed in this disclosure can be combined, separated, interchanged and / or rearranged with each other. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0033] In the accompanying drawings, the size and relative size of components may be exaggerated for clarity and / or descriptive purposes. When the exemplary embodiments may be implemented differently, a specific process sequence may be performed in a different order than described. For example, two successively described processes may be performed substantially simultaneously or in an order opposite to the order described. In addition, the same reference numerals represent the same components.
[0034] Example 1
[0035] A specific embodiment of the present invention, as Figure 1 As shown, a training method of a hybrid expert model based on a decision tree is disclosed, comprising:
[0036] Get the data set to be trained;
[0037] Inputting the data set to be trained into a decision tree router for classification, so as to distribute the data set to be trained to leaf nodes of the decision tree;
[0038] According to the leaf nodes, determining the number of sub-expert models in the hybrid expert model, and establishing an association relationship between the leaf nodes and the sub-expert models;
[0039] According to the association relationship, the data in each leaf node is input into the corresponding sub-expert model for training;
[0040] Back propagation training is performed based on the training results of the sub-expert models to update the parameters of the decision tree router to obtain the hybrid expert model.
[0041] During implementation, the collected data set is labeled to obtain the data set to be trained, and the data set is input into the decision tree router provided with a decision tree algorithm for training to generate a decision tree model so as to distribute the data set to be trained to each leaf node of the decision tree model; then the number of the sub-expert models required is determined according to the number of the leaf nodes, and an association relationship between each leaf node and each sub-expert model is established; finally, the data in each leaf node is input into the corresponding sub-expert model according to the association relationship to train the sub-expert model, and then back-propagation training is performed according to the training results to update the parameters of the decision tree router, and all the sub-expert models are integrated to obtain the hybrid expert model.
[0042] Compared with the prior art, the training method of the hybrid expert model based on decision trees provided in this embodiment distributes the data set to leaf nodes through a decision tree router equipped with a decision tree algorithm, and trains the data in each leaf node respectively through sub-expert models with the same number as the leaf nodes, thereby achieving balanced distribution of sub-expert models and avoiding problems such as overfitting and waste of resources.
[0043] It should be noted that the decision tree algorithm used in this embodiment can be ID3, CART, C4.5, etc. The sub-expert model is selected according to the type and characteristics of the data set, and can be a neural network, support vector machine, random forest, etc., which is not limited in this embodiment.
[0044] In this embodiment, before the data set to be trained is input into the decision tree router, the data set to be trained is also preprocessed, and the preprocessing includes data cleaning, normalization and outlier removal.
[0045] In this embodiment, the step of inputting the data set to be trained into the decision tree router for classification includes:
[0046] The decision tree router includes a plurality of decision trees with a depth of 1;
[0047] The decision tree with a depth of 1 distributes the input data set to two nodes of the decision tree through Gini impurity;
[0048] If the Gini impurity of a node of the decision tree is greater than a preset threshold, the data set in the node is input into the next layer of the decision tree with a depth of 1 to continue classification;
[0049] When the Gini impurity of the node of the decision tree is less than the preset threshold, the node at this time is set as a leaf node.
[0050] Specifically, in this embodiment, the decision tree router is designed as a plurality of decision trees with a depth of 1 according to the size of the data set; the decision trees with a depth of 1 have a simple structure, low computational complexity of training and prediction, fast processing speed, and can effectively prevent overfitting; the data input into each decision tree is distributed to two nodes of the decision tree, and then input into the next level decision tree, and the Gini impurity of the nodes of each level of the decision tree is calculated until the Gini impurity is less than a preset threshold, the node of the decision tree at this time is set as a leaf node, and the data is stopped from being further distributed. The Gini impurity is expressed as follows:
[0051]
[0052] Among them, t represents the node, c represents the number of categories, and p(i|t) represents the proportion of samples belonging to category i in node t.
[0053] In this embodiment, each decision tree has an allocation standard as shown below, and the allocation standard is used to balance the size of the data set allocated to the nodes of the decision tree;
[0054] abs(|{f(g n )>0}|-|{f(gn)≤0}|)
[0055] Among them, g n represents the gradient of the nth data sample with respect to the mixed expert model, f(g n ) represents mapping gn to a real number, |{·}| represents the size of the set, and abs(·) represents the absolute value.
[0056] Specifically, by setting the allocation criteria in each decision tree, each set of data input into each decision tree is distributed as evenly as possible to the two nodes of the decision tree, so that the data processed by each sub-expert model is as equal as possible, and computing resources are used rationally.
[0057] In this embodiment, the establishing of the association relationship between the leaf node and the sub-expert model includes:
[0058] By training the reinforcement learning model, a sub-expert model is matched for each leaf node, specifically including:
[0059] Constructing an environment to simulate the matching process between the leaf node and the sub-expert model;
[0060] Set the action space and reward signal;
[0061] Obtaining a matching strategy according to the characteristics of the leaf node and the action space;
[0062] The reinforcement learning model is trained according to the result of the matching strategy and the reward signal to obtain an optimal matching strategy.
[0063] Specifically, after the data set to be trained is assigned to the leaf node, in order to make different sub-expert models responsible for processing different types of data, it is necessary to match the most suitable sub-expert model for each leaf node to maximize the functions of different sub-expert models. By training reinforcement learning models such as Q-learning and deep Q networks, the optimal matching strategy between leaf nodes and sub-expert models is obtained, that is, the association relationship between the leaf nodes and the sub-expert models.
[0064] In some embodiments, establishing the association relationship between the leaf node and the sub-expert model further includes:
[0065] Searching the association relationship between the leaf node and the sub-expert model by an optimization search algorithm specifically includes:
[0066] Constructing a search space to represent all possible associations between the leaf nodes and the sub-expert models;
[0067] defining a fitness function to evaluate the quality of each of the association relationships;
[0068] The optimal association relationship in the search space is searched according to the fitness function through the optimization search algorithm.
[0069] Specifically, another way to establish the association relationship between the leaf node and the sub-expert model is to search the association relationship between the leaf node and the sub-expert model through an optimized search algorithm. Compared with matching one sub-expert model for each leaf node through training a reinforcement learning model, the accuracy of the association relationship searched through the optimized search algorithm is relatively high, but the search efficiency is relatively reduced.
[0070] In this embodiment, the parameters of the hybrid expert model are adjusted by cross-validation, specifically including:
[0071] Divide the data set to be trained into K subsets;
[0072] Each of the subsets is used as a validation set, and the remaining K-1 subsets are used as training sets;
[0073] Training the hybrid expert model on the training set, and evaluating the performance of the hybrid expert model on the validation set;
[0074] Calculate the average performance of the hybrid expert model after K training times;
[0075] The parameters of the hybrid expert model are adjusted according to the average performance to obtain an optimal model.
[0076] Specifically, by repeatedly training and validating the model on different data subsets through cross-validation, the generalization ability of the model on unknown data can be more accurately evaluated to avoid overfitting or underfitting problems; adjusting the parameters of the mixed expert model through the average performance obtained through cross-validation can improve the performance and generalization ability of the model.
[0077] In this embodiment, the method further includes adjusting the parameters of the hybrid expert model through back propagation to minimize the loss function of the hybrid expert model.
[0078] Specifically, the training process of the hybrid expert model also includes back propagation, and the specific steps are:
[0079] (I) defining a loss function of the hybrid expert model;
[0080] (II) inputting the data set to be trained into the hybrid expert model, and calculating the predicted output of the model through forward propagation;
[0081] (III) calculating the value of the loss function by comparing the predicted output with the actual label to measure the prediction error of the model;
[0082] (IV) calculating the gradient of the current loss function with respect to the model parameters through the back propagation;
[0083] (V) adjusting the parameters of the hybrid expert model by a gradient descent method to minimize the value of the loss function.
[0084] In this embodiment, when the hybrid expert model is used, the parameters of the sub-expert model are adjusted in real time according to the characteristics of the input data set.
[0085] Specifically, when using the trained hybrid expert model for prediction, the parameters of the sub-expert model are dynamically adjusted in real time according to the characteristics of the input unknown data set that is different from the training set to adapt to the characteristics of the new input data, thereby improving the accuracy and generalization ability of the hybrid expert model.
[0086] Example 2
[0087] This embodiment provides a training device for a hybrid expert model based on a decision tree, such as Figure 2 As shown, including:
[0088] An acquisition module is used to obtain the data set to be trained;
[0089] An allocation module, used for inputting the data set to be trained into a decision tree router for classification, so as to allocate the data set to be trained to the leaf nodes of the decision tree;
[0090] An association module, used to determine the number of sub-expert models in the hybrid expert model according to the leaf node, and establish an association relationship between the leaf node and the sub-expert model;
[0091] A training module is used to input the data in each leaf node into the corresponding sub-expert model for training according to the association relationship; and perform back propagation training based on the training results of the sub-expert model to update the parameters of the decision tree router to obtain the hybrid expert model.
[0092] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A training method for a hybrid expert model based on a decision tree, characterized in that: include: Get the data set to be trained; Inputting the data set to be trained into a decision tree router for classification, so as to distribute the data set to be trained to leaf nodes of the decision tree; According to the leaf nodes, determining the number of sub-expert models in the hybrid expert model, and establishing an association relationship between the leaf nodes and the sub-expert models; According to the association relationship, the data in each leaf node is input into the corresponding sub-expert model for training; Back propagation training is performed based on the training results of the sub-expert models to update the parameters of the decision tree router to obtain the hybrid expert model.
2. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: Before the data set to be trained is input into the decision tree router, the data set to be trained is also preprocessed, and the preprocessing includes data cleaning, normalization and outlier removal.
3. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: The step of inputting the data set to be trained into the decision tree router for classification includes: The decision tree router includes a plurality of decision trees with a depth of 1; The decision tree with a depth of 1 distributes the input data set to two nodes of the decision tree through Gini impurity; If the Gini impurity of a node of the decision tree is greater than a preset threshold, the data set in the node is input into the next layer of the decision tree with a depth of 1 to continue classification; When the Gini impurity of the node of the decision tree is less than the preset threshold, the node at this time is set as a leaf node.
4. The training method of the hybrid expert model based on decision tree according to claim 3 is characterized in that: Each of the decision trees has an allocation criterion as shown below, and the allocation criterion is used to balance the size of the data set allocated to the nodes of the decision tree; abs(|{f(g n )>0}|-|{f(g n )≤0}|) Among them, g n represents the gradient of the nth data sample with respect to the mixed expert model, f(g n ) means to convert g n Mapped to a real number, |{·}| represents the size of the set, and abs(·) represents the absolute value.
5. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: The establishing of the association relationship between the leaf node and the sub-expert model includes: By training the reinforcement learning model, a sub-expert model is matched for each leaf node, specifically including: Constructing an environment to simulate the matching process between the leaf node and the sub-expert model; Set the action space and reward signal; Obtaining a matching strategy according to the characteristics of the leaf node and the action space; The reinforcement learning model is trained according to the result of the matching strategy and the reward signal to obtain an optimal matching strategy.
6. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: The establishing of the association relationship between the leaf node and the sub-expert model further includes: Searching the association relationship between the leaf node and the sub-expert model by an optimization search algorithm specifically includes: Constructing a search space to represent all possible associations between the leaf nodes and the sub-expert models; defining a fitness function to evaluate the quality of each of the association relationships; The optimal association relationship in the search space is searched according to the fitness function through the optimization search algorithm.
7. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: The method also includes adjusting the parameters of the hybrid expert model through cross-validation, specifically including: Divide the data set to be trained into K subsets; Each of the subsets is used as a validation set, and the remaining K-1 subsets are used as training sets; Training the hybrid expert model on the training set, and evaluating the performance of the hybrid expert model on the validation set; Calculate the average performance of the hybrid expert model after K training times; The parameters of the hybrid expert model are adjusted according to the average performance to obtain an optimal model.
8. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: It also includes adjusting the parameters of the hybrid expert model through back propagation to minimize the loss function of the hybrid expert model.
9. The training method of the hybrid expert model based on decision tree according to claim 1, characterized in that: It also includes adjusting the parameters of the sub-expert model in real time according to the characteristics of the input data set when using the hybrid expert model.
10. A training device for a hybrid expert model based on a decision tree, characterized in that: The device comprises: An acquisition module is used to obtain the data set to be trained; An allocation module, used for inputting the data set to be trained into a decision tree router for classification, so as to allocate the data set to be trained to the leaf nodes of the decision tree; An association module, used to determine the number of sub-expert models in the hybrid expert model according to the leaf node, and establish an association relationship between the leaf node and the sub-expert model; A training module is used to input the data in each leaf node into the corresponding sub-expert model for training according to the association relationship; and perform back propagation training based on the training results of the sub-expert model to update the parameters of the decision tree router to obtain the hybrid expert model.
