Large language model training method and device, electronic equipment and storage medium

By performing dimensionality reduction and parameter fusion on large language models, combined with training using the objective loss function, the problems of high computational resources and memory consumption are solved, and efficient model training is achieved.

CN118520907BActive Publication Date: 2025-11-18BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410599492.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-14
Publication Date
2025-11-18
Estimated Expiration
2044-05-14

AI Technical Summary

Technical Problem

Existing technologies consume significant computational resources and memory when training large language models, and inaccurate positioning of redundant parameters may lead to a decline in language processing capabilities.

Method used

By performing dimensionality reduction parameter fusion and layer reduction parameter fusion on the network layers of a large language model, and combining this with the target loss function, a target large language model with a smaller parameter scale is trained.

Benefits of technology

While maintaining model accuracy, it reduces the computational and memory resource consumption during training, thereby improving training efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118520907B_ABST
    Figure CN118520907B_ABST
Patent Text Reader

Abstract

The present disclosure provides a large language model training method and device, electronic equipment and storage medium, relating to the technical field of artificial intelligence, in particular to the field of deep learning, the field of natural language processing and the field of large model. The specific implementation scheme is: performing dimension reduction parameter fusion on the two-dimensional parameter matrix on each channel in each network layer of the first large language model to obtain a second large language model; performing layer reduction parameter fusion on the network layers in the second large language model based on the three-dimensional parameter matrix of each network layer of the second large language model to obtain a third large language model; and in the case that a target loss function determined based on the first large language model and the third large language model satisfies a first function condition, training the third large language model to obtain a target large language model. By using the present disclosure, the computing resources and memory resources occupied in the large language model training process can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the fields of deep learning, natural language processing, and large-scale models. Specifically, this disclosure relates to a method, apparatus, electronic device, and storage medium for training large-scale language models. Background Technology

[0002] With the continuous improvement of artificial intelligence technology, Natural Language Processing (NLP) models have entered the era of ultra-large-scale models. Large Language Models (LLMs) with extremely large parameter sizes can be trained on massive amounts of text data using powerful computing capabilities. These large language models possess semantic understanding and generation capabilities for multiple tasks and few-shot learning. However, considering the computational resources and memory consumption involved in model training, using large language models with relatively smaller parameter sizes is a more economical choice for commercial applications. Summary of the Invention

[0003] This disclosure provides a method, apparatus, electronic device, and storage medium for training large language models.

[0004] According to one aspect of this disclosure, a method for training a large language model is provided, comprising:

[0005] The second language model is obtained by performing dimensionality reduction and parameter fusion on the two-dimensional parameter matrix of each channel in each network layer of the first language model.

[0006] Based on the three-dimensional parameter matrix of each network layer in the second language model, the network layer parameters in the second language model are fused to obtain the third language model.

[0007] Based on the first and third language models, the target loss function is determined;

[0008] If the target loss function satisfies the preset first function condition, the third large language model is trained to obtain the target large language model.

[0009] According to another aspect of this disclosure, a large language model training apparatus is provided, comprising:

[0010] The dimension reduction parameter fusion module is used to perform dimension reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network layer of the first language model to obtain the second language model.

[0011] The layer reduction parameter fusion module is used to perform layer reduction parameter fusion on the network layers in the second large language model based on the three-dimensional parameter matrix of each network layer in the second large language model to obtain the third large language model.

[0012] The objective function determination module is used to determine the objective loss function based on the first large language model and the third large language model;

[0013] The model training module is used to train the third large language model to obtain the target large language model when the target loss function satisfies the preset first function condition.

[0014] According to another aspect of this disclosure, an electronic device is provided, comprising:

[0015] At least one central processing unit; and

[0016] A memory communicatively connected to the at least one central processing unit; wherein,

[0017] The memory stores instructions that can be executed by the at least one central processing unit (CPU) to enable the at least one CPU to perform any of the large language model training methods in the embodiments of this disclosure.

[0018] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform any of the large language model training methods in the embodiments of this disclosure.

[0019] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements any of the large language model training methods according to embodiments of this disclosure.

[0020] According to the technique disclosed herein, the two-dimensional parameter matrices of each channel in the subdivided network layers of the first large language model are dimensionality-reduced and fused to obtain the second large language model. Then, the network layers of the second large language model are further dimensionality-reduced and fused to obtain the third large language model with a smaller parameter scale. If the loss functions corresponding to the first and third large language models satisfy the first function condition, the third large language model is trained to obtain the target large language model. In this way, while maintaining the training effect of the large language model, the computational and memory resources consumed during the training process can be reduced.

[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0022] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0023] Figure 1 This is a flowchart of a large language model training method according to an embodiment of the present disclosure;

[0024] Figure 2 This is a schematic diagram illustrating the degree of similarity between parameters of each network layer in a large language model according to an embodiment of this disclosure;

[0025] Figure 3 This is a schematic diagram illustrating the degree of similarity between parameters of each network layer in a large language model according to another embodiment of this disclosure;

[0026] Figure 4 This is a schematic diagram of the fusion process of a large language model according to an embodiment of the present disclosure;

[0027] Figure 5 This is a schematic diagram of the dimensional fusion process of a large language model according to an embodiment of the present disclosure;

[0028] Figure 6 This is a schematic diagram of the layer fusion process of a large language model according to an embodiment of the present disclosure;

[0029] Figure 7 This is a structural block diagram of a large language model training device according to an embodiment of the present disclosure;

[0030] Figure 8 This is a structural block diagram of a large language model training device according to another embodiment of the present disclosure;

[0031] Figure 9 This is a block diagram of an electronic device according to an embodiment of the present disclosure. Detailed Implementation

[0032] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0033] To facilitate understanding of the large language model training method provided in the embodiments of this disclosure, the relevant technologies of the embodiments of this disclosure are described below. The following relevant technologies are optional solutions and can be combined with the technical solutions of the embodiments of this disclosure in any way, and they all fall within the protection scope of the embodiments of this disclosure.

[0034] In some techniques, the parameters of a large language model with a small parameter size are randomly initialized. Then, a large amount of text training data is used to pre-train or train the small language model to obtain the target large language model. However, this technique cannot utilize existing large language models with a large parameter size and high accuracy. Moreover, the training process of this small language model still consumes a lot of computational and memory resources, resulting in low training efficiency.

[0035] In some techniques, redundant parameters of an existing, large-scale, and highly accurate language model are located, and then these redundant parameters are removed to obtain a more compact language model. This compact model is then pre-trained or trained to obtain the target language model. However, if the location of redundant parameters is inaccurate, the language processing capabilities of the pruned language model may decrease, and the accuracy of the target language model obtained by training the pruned model may not meet requirements.

[0036] Therefore, this disclosure provides a method for training large language models that can overcome the above-mentioned shortcomings.

[0037] Figure 1 This is a flowchart of a large language model training method according to an embodiment of this disclosure. The method can be applied to electronic devices. These electronic devices may be terminals, servers, or other processing devices. The terminal may be a desktop computer, mobile device, PDA (Personal Digital Assistant), handheld device, computing device, in-vehicle device, wearable device, or other user equipment (UE). In some implementations, the electronic device can implement the large language model training method of this disclosure by having a central processing unit call computer-readable instructions stored in memory.

[0038] like Figure 1 As shown, the method may include the following steps:

[0039] S110, dimensionality reduction and parameter fusion are performed on the two-dimensional parameter matrices of each channel in each network layer of the first language model to obtain the second language model;

[0040] S120, based on the three-dimensional parameter matrix of each network layer in the second language model, performs parameter fusion on the network layers in the second language model to obtain the third language model;

[0041] S130, based on the first and third largest language models, determines the target loss function;

[0042] S140, under the condition that the target loss function satisfies the preset first function condition, the third large language model is trained to obtain the target large language model.

[0043] Understandably, steps S110 to S130 can be executed repeatedly until the target loss function satisfies the preset first function condition, at which point step S140 is executed.

[0044] Understandably, any of the large language models in the embodiments of this disclosure can understand, recognize, or generate another text from the text.

[0045] Understandably, during each execution of steps S110 to S130, the model parameters of the first large language model can be updated, for example, the first large language model can be trained. Steps S110 to S130 are then executed using the updated first large language model.

[0046] Understandably, performing steps S110 to S130 once constitutes one training operation in pre-training. Pre-training includes steps S110 to S140, wherein steps S110 to S130 can be executed multiple times in a loop.

[0047] Understandably, a model can include multiple network layers, such as an input layer, fully connected layers, attention layers, embedding layers, and an output layer. A network layer can include multiple channels, each with a two-dimensional parameter matrix. By merging the two-dimensional parameter matrices of each channel in a network layer, we obtain the three-dimensional parameter matrix of that network layer.

[0048] Understandably, a two-dimensional parameter matrix includes parameters with multiple rows and columns. A three-dimensional parameter matrix includes parameters with multiple channels and multiple rows and columns.

[0049] Understandably, the parameter size of the first largest language model is larger than that of the second largest language model. The parameter size of the second largest language model is larger than that of the third largest language model.

[0050] For example, in the first language model, the number of rows in the two-dimensional parameter matrix of the first channel in the first network layer is greater than or equal to the number of rows in the two-dimensional parameter matrix of the first channel in the first network layer of the second language model. Similarly, the number of columns in the two-dimensional parameter matrix of the first channel in the first network layer of the first language model is greater than or equal to the number of columns in the two-dimensional parameter matrix of the first channel in the first network layer of the second language model.

[0051] For example, the number of network layers in the first largest language model is greater than the number of network layers in the third largest language model. The number of network layers in the first largest language model is equal to the number of network layers in the second largest language model. The number of network layers in the second largest language model is greater than the number of network layers in the third largest language model.

[0052] In some embodiments, only step S110 or step S120 may be performed, namely, performing the above-mentioned dimensionality reduction parameter fusion or the above-mentioned layer reduction parameter fusion on the first large language model with a large parameter scale, and then using the fused large language model and the first large language model to determine the target loss function. If the target loss function satisfies the preset function condition, the fused large language model is trained to obtain the target large language model.

[0053] For example, the first large language model can be a pre-trained large language model that remains unchanged each time steps S110 to S130 are executed. Alternatively, except for the first execution of steps S110 to S130, the first large language model can be updated using the target loss function each time steps S110 to S130 are executed, and steps S110 to S130 can be executed using the updated first large language model.

[0054] For example, a dimensionality fusion operator is used to perform dimensionality reduction parameter fusion on the two-dimensional parameter matrices of each channel in each network layer of the first large language model to obtain the second large language model. A layer fusion operator is then used to perform layer-level parameter fusion on the network layers of the second large language model based on the three-dimensional parameter matrices of each network layer to obtain the third large language model.

[0055] During the first execution of steps S110 to S130, the dimension fusion operator can be randomly initialized. In each subsequent execution of steps S110 to S130, the dimension fusion operator and the layer fusion operator are updated using the target loss function, and then steps S110 to S130 are executed using the updated dimension fusion operator and the layer fusion operator.

[0056] Understandably, the objective loss function can characterize the functional differences between the first and second largest language models.

[0057] For example, the target loss function can be determined using the output distributions of the first and third largest language models.

[0058] For example, the target loss function can be determined using the loss functions of the first and third largest language models.

[0059] For example, a loss function is determined using the output distributions of the first and third language models, and then combined with the loss functions of the first and third language models to obtain the target loss function.

[0060] Figure 2 This is a schematic diagram illustrating the similarity between parameters of each network layer in a large language model according to an embodiment of this disclosure. Figure 3 This is a schematic diagram illustrating the degree of similarity between parameters of each network layer in a large language model according to another embodiment of this disclosure.

[0061] in, Figure 2 The horizontal and vertical axes in the graph represent the network layer number in the large language model, and the gray level of the gray bars represents the similarity. Furthermore, lighter gray levels indicate higher similarity, and darker gray levels indicate lower similarity. Figure 2 It can be seen that the closer two network layers are in the large language model, the higher the similarity. Moreover, the similarity between the network layers in this model exhibits a clustered structure, which indicates that there are a large number of redundant parameters in the model.

[0062] in, Figure 3 The horizontal axis represents the number of network layers in the large language model, and the vertical axis represents the similarity between a network layer and a specified network layer. For example... Figure 3 As shown, the maximum similarity between a network layer and a specified network layer is less than 80%, which means that each network layer has a specific function and a network layer cannot be simply deleted directly.

[0063] Therefore, the present invention employs parameter fusion to reduce the parameter size in the large language model, which ensures that the accuracy or performance of the fused large language model will not decrease excessively.

[0064] Figure 4 This is a schematic diagram of the fusion process of a large language model according to an embodiment of the present disclosure.

[0065] For example, such as Figure 4 As shown, in the iterative process of executing steps S110 to S130 above, the goal of this example is to learn a fusion operator such that the original parameters (the large language model with a large parameter scale), i.e., the first large language model mentioned above, and the target parameters obtained after fusion (the large language model with a smaller parameter scale), i.e., the second or third large language model mentioned above, are fused together. This goal can be defined as:

[0066] in

[0067] in, Let L be the fusion operator, D be the target loss function, and x be a training sample in the training set. small For the parameters of a large language model with a relatively small parameter size (hereinafter referred to as a small model), Θ large These are the parameters of a large language model (hereinafter referred to as a large model) with a large parameter scale.

[0068] In one example, the fusion operator can be used. Decomposed into layer fusion operator γ and dimension fusion operator R dim The fusion operation is performed in two directions: inter-layer fusion and intra-layer fusion. Inter-layer fusion (layer fusion) fuses the parameters of each network layer, while intra-layer fusion (dimensional fusion) fuses the parameters of a single network layer.

[0069] like Figure 4 As shown, the layer fusion operator γ includes mapping coefficients from each network layer in the large model to each network layer in the small model, where L1 represents the number of network layers in the large model and L2 represents the number of network layers in the small model. The dimension fusion operator R... dim This can include a dimension fusion operator that corresponds one-to-one with each channel in each network layer of the large model. This dimension fusion operator can be decomposed into a row transformation matrix A or A2. * The column transformation matrix B or B * .For example, This represents the row transformation matrix of the first network layer in the large model.

[0070] Therefore, according to the above implementation method, by performing dimensional fusion and layer fusion on the large model until the above objective is achieved, a target small model can be obtained. Then, by pre-training or training the target small model, the target large language model can be obtained. In this way, the accuracy of the large language model is guaranteed, while reducing the consumption of computing and memory resources during the model training process.

[0071] In one implementation, dimensionality reduction parameter fusion is performed on the two-dimensional parameter matrices of each channel in each network layer of the first large language model to obtain the second large language model. This includes: decomposing the dimensionality fusion operator to obtain the column transformation matrix and row transformation matrix corresponding to each channel in each network layer of the first large language model; based on the column transformation matrix corresponding to each channel in each network layer of the first large language model, performing dimensionality reduction parameter fusion on the two-dimensional parameter matrices of each channel in each network layer of the first large language model to obtain the fourth large language model; and based on the row transformation matrix corresponding to each channel in each network layer of the first large language model, performing dimensionality reduction parameter fusion on the two-dimensional parameter matrices of each channel in each network layer of the fourth large language model to obtain the second large language model.

[0072] Understandably, the dimension fusion operator is a matrix, where each element corresponds to a channel fusion operator, and this fusion operator can be split into a column transformation matrix and a row transformation matrix.

[0073] Understandably, the fourth language model is obtained by multiplying the column transformation matrix corresponding to each channel in each network layer of the first language model with the corresponding two-dimensional parameter matrix in the first language model.

[0074] For example, by multiplying the column transformation matrix corresponding to the first channel in the first language model with the two-dimensional parameter matrix of the first channel in the first language model, and performing this multiplication operation for each channel, a fourth language model can be obtained.

[0075] Continuing the previous example, the number of rows in the column transformation matrix corresponding to the first channel is greater than or equal to the number of columns. The number of rows in this column transformation matrix is ​​the same as the number of columns in the two-dimensional parameter matrix of the first channel in the first language model. The number of columns in this column transformation matrix is ​​the same as the number of columns in the two-dimensional parameter matrix of the first channel in the fourth language model. In other words, the number of columns in this column transformation matrix is ​​the same as the number of columns in the two-dimensional parameter matrix of the first channel in the second language model. Therefore, after column transformation, the effect of dimensionality reduction and parameter fusion at the column level can be achieved.

[0076] Understandably, the second language model is obtained by multiplying the row transformation matrix corresponding to each channel in each network layer of the first language model with the corresponding two-dimensional parameter matrix in the fourth language model.

[0077] For example, by multiplying the row transformation matrix corresponding to the first channel in the first language model with the two-dimensional parameter matrix on the first channel in the fourth language model, and performing this multiplication operation for each channel, the fourth language model can be obtained.

[0078] Continuing the previous example, the row transformation matrix corresponding to the first channel has a number of rows greater than or equal to its number of columns. The number of rows in this column transformation matrix is ​​the same as the number of rows in the two-dimensional parameter matrix of the first channel in the first language model, and the number of columns in this column transformation matrix is ​​the same as the number of rows in the two-dimensional parameter matrix of the first channel in the second language model. Thus, after row transformation, the effect of dimensionality reduction and parameter fusion at the row level can be achieved.

[0079] For example, the two-dimensional parameter matrix on the first channel in the first large language model (large model) For example, in order to make W large Dimensionally reduced to a two-dimensional parameter matrix on the first channel of the second largest language model (small model) Its corresponding column transformation matrix is The row transformation matrix is Where D1 and D2 are two-dimensional parameter matrices Wlarge The number of rows and columns, D3 and D4 are two-dimensional parameter matrices W. small The number of rows and columns.

[0080] For example, the two-dimensional parameter matrix W corresponding to the small model can be obtained through the following operation. small .

[0081]

[0082] According to the above implementation method, in the dimension reduction parameter fusion, the dimension fusion operator is decomposed into column transformation matrix and row transformation matrix. The two-dimensional parameter matrix of the large model is first subjected to column dimension reduction fusion and then row dimension reduction fusion. This can reduce the computing and memory resources occupied by the model parameters in the dimension reduction fusion process and improve the dimension reduction fusion speed of the model parameters.

[0083] In one implementation, based on the column transformation matrix corresponding to each channel in each network layer of the first large language model, the two-dimensional parameter matrix of each channel in each network layer of the first large language model is subjected to column-dimensionality reduction parameter fusion to obtain the fourth large language model. This includes: for the first column transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the first difference between the number of rows of the first column transformation matrix and the number of columns of the corresponding two-dimensional parameter matrix in the first large language model satisfies the first difference condition, the first column transformation matrix is ​​updated based on the ratio between the number of rows of the first column transformation matrix and the preset column receptive field value; the updated first column transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform column-dimensionality reduction parameter fusion; wherein the column receptive field value is greater than 1.

[0084] Understandably, if the number of rows in the first column of the transformation matrix is ​​similar to the number of columns in the corresponding two-dimensional parameter matrix of the first large language model, the size of the first column of the transformation matrix will be large, leading to excessive resource consumption in the subsequent dimensionality reduction and parameter fusion process. Therefore, in order to minimize the demand for memory and computing resources during the training process, the column receptive field value can be used to reduce the row dimension of the first column of the transformation matrix, thereby reducing the size of the first column of the transformation matrix after dimensionality reduction and decreasing the consumption of computing and memory resources in the subsequent dimensionality reduction and parameter fusion process.

[0085] For example, the first difference condition is that the first difference is greater than or equal to zero or some negative number.

[0086] For example, the number of rows in the updated first column transformation matrix is ​​the ratio of the number of rows in the original first column transformation matrix to a preset column receptive field value. The number of columns in the updated first column transformation matrix is ​​the same as the number of columns in the original first column transformation matrix.

[0087] For example, the column transformation matrix before the update is The updated column transformation matrix is Where, r A The pre-defined column receptive field values. Thus, the original column transformation matrix A with D2×D4 parameters can be reduced to a matrix with only (D2 / r) parameters. A A column transformation matrix A with 4 parameters (D) × D * Among them, r A Greater than 1.

[0088] According to the above implementation method, the dimensionality of the row dimension in the column transformation matrix is ​​reduced first, and then the dimensionality-reduced column transformation matrix is ​​multiplied with the corresponding two-dimensional parameter matrix in the large model to achieve the dimensionality reduction parameter fusion of the column dimension. In this way, the computational and memory resources occupied during the training process can be further reduced.

[0089] In one implementation, based on the row transformation matrix corresponding to each channel in each network layer of the first large language model, the two-dimensional parameter matrix of each channel in each network of the fourth large language model is subjected to row-dimensionality reduction parameter fusion to obtain the second large language model. This includes: for the first row transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the second difference between the number of rows in the first row transformation matrix and the number of rows in the corresponding two-dimensional parameter matrix in the first large language model satisfies the second difference condition, the first row transformation matrix is ​​updated based on the ratio between the number of rows in the first row transformation matrix and a preset row receptive field value; the updated first row transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform row-dimensionality reduction parameter fusion; wherein the row receptive field value is greater than 1.

[0090] Understandably, if the number of rows in the first row transformation matrix is ​​similar to the number of rows in the corresponding two-dimensional parameter matrix of the largest language model, the size of the first row transformation matrix will be large, leading to excessive resource consumption in the subsequent dimensionality reduction and parameter fusion process. Therefore, to minimize the memory and computational resource requirements of the training process, the row receptive field value can be used to reduce the row dimension of the first row transformation matrix, thereby reducing the size of the dimensionality-reduced first row transformation matrix and decreasing the computational and memory resource consumption of the subsequent dimensionality reduction and parameter fusion process.

[0091] For example, the second difference condition is that the second difference is greater than or equal to zero or some negative number.

[0092] For example, the number of rows in the updated first row transformation matrix is ​​the ratio of the number of rows in the original first row transformation matrix to a preset row receptive field value. The number of columns in the updated first column transformation matrix is ​​the same as the number of columns in the original first column transformation matrix.

[0093] For example, the row transformation matrix before the update is The updated row transformation matrix is Where, r B r is the pre-set receptive field value. B Greater than 1. Thus, the original row transformation matrix B with D1×D3 parameters can be reduced to one with only (D1 / r) parameters. B A row transformation matrix B with 3 parameters (D) × D * .

[0094] For example, such as Figure 5 As shown, this is the process of dimensionality reduction parameter fusion. Figure 4 Part ②, Dimensional Fusion. This refers to the two-dimensional parameter matrix on a certain channel of the l-th layer in a large model. That is, the original parameters, with the receptive field being r. A Matrix A * The large model is linearly fused using column-dimensional vectors, and then the receptive field is r. B Matrix B * The large model is then subjected to linear fusion of row-dimensional vectors, ultimately yielding the parameter matrix for a specific channel in the l-th layer of the corresponding small model. That is, the target parameter.

[0095] According to the above implementation method, the dimensionality of the row dimension in the row transformation matrix is ​​first reduced, and then the dimensionality-reduced row transformation matrix is ​​multiplied with the corresponding two-dimensional parameter matrix in the large model to achieve the dimensionality reduction parameter fusion of the row dimension. In this way, the computational and memory resources occupied by the training process of the large language model can be further reduced.

[0096] In one implementation, the method may further include: adjusting the dimension fusion operator based on the target loss function when the target loss function does not satisfy the first function condition.

[0097] Understandably, the gradient information in the target loss function is used to update or adjust the dimension fusion operator. Then, the updated or adjusted dimension fusion operator is used to return to and continue executing the steps of dimension reduction parameter fusion, layer reduction parameter fusion, and target loss function calculation, until the target loss function meets the first function condition.

[0098] Understandably, some or all of the parameters of the dimension fusion operator can be adjusted.

[0099] Understandably, even if the target loss function does not satisfy the first function condition, the parameters of the first large language model are simultaneously updated or adjusted based on the target loss function. Then, using the updated first large language model and the updated or adjusted dimension fusion operator, the process returns to continue executing steps S110 to S130 until the target loss function satisfies the first function condition.

[0100] According to the above implementation method, during the pre-training process, by continuously adjusting the dimensionality fusion operator, the functional difference between the first and third language models can be minimized, that is, the target loss function meets the first function condition.

[0101] In one implementation, a third language model is obtained by performing layer fusion on the network layers in the second language model based on the three-dimensional parameter matrices of each network layer in the second language model. This includes: determining the mapping coefficients from each network layer in the first model to each network layer in the second model based on a layer fusion operator, wherein the number of network layers in the first model is the same as the number of network layers in the second language model; obtaining the three-dimensional parameter matrix of each second network layer in the second model based on the three-dimensional parameter matrices of each network layer in the second language model and the mapping coefficients from each network layer in the first model to the second network layer; and determining the third language model based on the three-dimensional parameter matrices of each second network layer.

[0102] Understandably, the layer fusion operator can be understood as the inter-layer mapping operator. This includes the mapping coefficients from each network layer in the first model to each network layer in the second model. Here, L1 represents the number of network layers in the first model, and L2 represents the number of network layers in the second model.

[0103] For example, the number of layers in the first model is greater than or equal to the number of layers in the second model.

[0104] For example, the first model is a large model and the second model is a small model.

[0105] It should be noted that, in the embodiments disclosed herein, a large model can be understood as a model with a large parameter scale, and a small model can be understood as a model with a small parameter scale.

[0106] The inter-layer mapping operator γ includes the mapping coefficients γ from the j-th layer in the first model to the i-th layer in the smaller model. i,j .

[0107] Understandably, the second network layer is any network layer in the second model.

[0108] Understandably, the first model corresponds to the second largest language model, and the second model corresponds to the third largest language model.

[0109] like Figure 4 and Figure 6 As shown, Figure 6 This refers to the process of fusing downsizing parameters. Figure 4 The first part, layer fusion, involves fusing the original network layers using the layer fusion operator γ to obtain a new network layer, the target layer.

[0110] According to the above implementation method, based on the three-dimensional parameter matrices of each network layer of the model with a larger parameter scale, and the mapping of each network layer in the model with a larger parameter scale to the second network layer specified in the model with a smaller parameter scale, a three-dimensional parameter matrix of the second network layer specified in the model with a smaller parameter scale can be obtained. Therefore, based on the three-dimensional parameter matrices of each second network layer, a third major language model can be constructed.

[0111] In one implementation, the three-dimensional parameter matrix of the second network layer is obtained based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients of each network layer in the first model to the second network layer. This includes: multiplying the three-dimensional parameter matrix of each network layer in the second large language model by the mapping coefficients of the corresponding network layer in the first model to the second network layer to obtain multiple three-dimensional parameter matrices; and summing the multiple three-dimensional parameter matrices to obtain the three-dimensional parameter matrix of the second network layer.

[0112] For example, for a given three-dimensional parameter matrix of the j-th layer in the second largest language model and inter-layer mapping operators The parameters of the i-th layer in the third language model The calculation formula is:

[0113]

[0114] As can be seen from the above, the parameters of each network layer in the small model can be obtained by linearly fusing the parameters of each network layer in the large model.

[0115] According to the above implementation method, the parameters of each layer of the large model and the mapping coefficients of each layer of the large model to the i-th layer of the small model are multiplied and summed to obtain the parameters of the i-th layer of the small model.

[0116] In one implementation, the method may further include: adjusting the layer fusion operator based on the target loss function when the target loss function does not satisfy the first function condition.

[0117] Understandably, if the target loss function does not satisfy the first function condition, the dimension fusion operator and the layer fusion operator are adjusted based on the target loss function.

[0118] Understandably, the gradient information in the target loss function is used to update or adjust the layer fusion operator. Then, the updated or adjusted layer fusion operator is used to return to and continue executing the steps of dimensionality reduction parameter fusion, layer reduction parameter fusion, and target loss function calculation, until the target loss function meets the first function condition.

[0119] Understandably, some or all of the parameters of the layer fusion operator can be adjusted.

[0120] Understandably, even if the target loss function does not satisfy the first function condition, the parameters of the first large language model are simultaneously updated or adjusted based on the target loss function. Then, using the updated first large language model and the updated or adjusted layer fusion operator and dimension fusion operator, the above steps S110 to S130 are repeated until the target loss function satisfies the first function condition.

[0121] According to the above implementation method, during the pre-training process, by continuously adjusting the layer fusion operator, the functional difference between the first and third language models can be minimized, that is, the target loss function meets the first function condition.

[0122] In one implementation, determining the target loss function based on a first large language model and a third large language model includes: determining a first loss function and a first output distribution of the first large language model based on a first training sample set; determining a second loss function and a second output distribution of the third large language model based on a second training sample set; determining a third loss function based on the first output distribution and the second output distribution; and performing a weighted summation of the first loss function, the second loss function, and the third loss function to obtain the target loss function.

[0123] Understandably, in order to quantify the difference in output distribution between large and small models, KL divergence can be added to the objective loss function.

[0124] Understandably, the first loss function measures the difference between the actual output and the labeled output when the first language model is trained using the first training sample set.

[0125] Understandably, the first output distribution measures the output distribution of the largest language model.

[0126] Understandably, the second loss function measures the difference between the actual output and the labeled output when the third language model is trained using the second training sample set.

[0127] Understandably, the second output distribution measures the output distribution of the third language model.

[0128] Understandably, the KL divergence function is used to calculate the first and second output distributions to obtain the target KL divergence, which is the third loss function.

[0129] For example, the target loss function is calculated using the following formula:

[0130] L final =λL lm +(1-λ)L kl

[0131] Among them, L final Let L be the target loss function. lm L is the sum of the first loss function and the second loss function. kl λ is the third loss function, and λ is the weighting coefficient.

[0132] According to the above implementation method, the objective loss function can measure not only the loss of the first major language model before fusion and the loss of the third major language model after fusion, but also the difference between the output distributions of the two models before and after fusion. Therefore, minimizing the objective loss function during training minimizes the difference in functionality and accuracy between the two models before and after fusion.

[0133] Figure 7 This is a structural block diagram of a large language model training device according to an embodiment of the present disclosure.

[0134] like Figure 7 As shown, the large language model training device may include:

[0135] The dimension reduction parameter fusion module 710 is used to perform dimension reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network layer of the first language model to obtain the second language model.

[0136] The layer reduction parameter fusion module 720 is used to perform layer reduction parameter fusion on the network layers in the second large language model based on the three-dimensional parameter matrix of each network layer in the second large language model to obtain the third large language model.

[0137] The objective function determination module 730 is used to determine the objective loss function based on the first large language model and the third large language model;

[0138] The model training module 740 is used to train the third large language model to obtain the target large language model when the target loss function satisfies the preset first function condition.

[0139] Figure 8 This is a structural block diagram of a large language model training device according to another embodiment of the present disclosure.

[0140] like Figure 7 and Figure 8 As shown, Figure 8 The dimensionality reduction parameter fusion module 810, the layer reduction parameter fusion module 820, the objective function determination module 830, and the model training module 840 are respectively connected to... Figure 7 The dimensionality reduction parameter fusion module 710, the layer reduction parameter fusion module 720, the objective function determination module 730, and the model training module 740 have the same structure and function, and will not be described in detail here.

[0141] In one implementation, such as Figure 8 As shown, the dimensionality reduction parameter fusion module 810 includes:

[0142] Operator decomposition unit 811 is used to decompose the dimension fusion operator to obtain the column transformation matrix and row transformation matrix corresponding to each channel in each network layer of the first large language model;

[0143] The column parameter fusion unit 812 is used to perform column dimension reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network layer of the first large language model based on the column transformation matrix corresponding to each channel in each network layer of the first large language model, so as to obtain the fourth large language model.

[0144] The row parameter fusion unit 813 is used to perform dimensionality reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network of the fourth language model based on the row transformation matrix corresponding to each channel in each network layer of the first language model, so as to obtain the second language model.

[0145] In one embodiment, the column parameter fusion unit 812 is specifically used for:

[0146] For the first column transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the first difference between the number of rows of the first column transformation matrix and the number of columns of the corresponding two-dimensional parameter matrix in the first large language model satisfies the first difference condition, the first column transformation matrix is ​​updated based on the ratio between the number of rows of the first column transformation matrix and the preset column receptive field value.

[0147] The updated first column transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform dimensionality reduction parameter fusion in the column dimension.

[0148] The receptive field value of the column is greater than 1.

[0149] In one embodiment, the row parameter fusion unit 813 is specifically used for:

[0150] For the first row transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the second difference between the number of rows of the first row transformation matrix and the number of rows of the corresponding two-dimensional parameter matrix in the first large language model satisfies the second difference condition, the first row transformation matrix is ​​updated based on the ratio between the number of rows of the first row transformation matrix and the preset row receptive field value.

[0151] The updated first row transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform dimensionality reduction parameter fusion in the row dimension.

[0152] The receptive field value is greater than 1.

[0153] In one implementation, such as Figure 8 As shown, the device also includes:

[0154] The first operator adjustment module 850 is used to adjust the dimension fusion operator based on the target loss function when the target loss function does not meet the first function condition.

[0155] In one implementation, such as Figure 8 As shown, the downsizing parameter fusion module 820 includes:

[0156] The mapping coefficient determination unit 821 is used to determine the mapping coefficients from each network layer in the first model to each network layer in the second model based on the layer fusion operator, wherein the number of network layers in the first model is the same as the number of network layers in the second large language model;

[0157] The mapping processing unit 822 is used to obtain the three-dimensional parameter matrix of the second network layer for each second network layer in the second model, based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients of each network layer in the first model to the second network layer.

[0158] The model determination unit 823 is used to determine the third major language model based on the three-dimensional parameter matrix of each of the second network layers.

[0159] In one embodiment, the mapping processing unit 822 is specifically used for:

[0160] The three-dimensional parameter matrices of each network layer in the second large language model are multiplied by the mapping coefficients from the corresponding network layer in the first model to the second network layer to obtain multiple three-dimensional parameter matrices.

[0161] The summation of the multiple three-dimensional parameter matrices yields the three-dimensional parameter matrix of the second network layer.

[0162] In one implementation, such as Figure 8 As shown, the device also includes:

[0163] The second operator adjustment module 860 is used to adjust the layer fusion operator based on the target loss function when the target loss function does not meet the first function condition.

[0164] In one implementation, such as Figure 8 As shown, the objective function determination module 830 includes:

[0165] The first function determination unit 831 is used to determine the first loss function and the first output distribution of the first large language model based on the first training sample set;

[0166] The second function determination unit 832 is used to determine the second loss function and the second output release of the third language model based on the second training sample set.

[0167] The third function determination unit 833 is used to determine a third loss function based on the first output distribution and the second output distribution;

[0168] The objective function determination unit 834 is used to perform a weighted summation of the first loss function, the second loss function, and the third loss function to obtain the objective loss function.

[0169] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.

[0170] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0171] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0172] Figure 9 A schematic block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0173] like Figure 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded into a random access memory (RAM) 903 from a storage unit 908. The RAM 903 may also store various programs and data required for the operation of the electronic device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0174] Multiple components in electronic device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of displays, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows electronic device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0175] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as a large language model training method. For example, in some embodiments, a large language model training method can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the large language model training method described above can be performed. Alternatively, in other embodiments, the computing unit 901 can be configured to perform a large language model training method by any other suitable means (e.g., by means of firmware).

[0176] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0177] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0178] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0179] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0180] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0181] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0182] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0183] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for training a large language model, comprising: The dimension fusion operator is decomposed into column transformation matrices and row transformation matrices. For each channel's two-dimensional parameter matrix in each network layer of the first large language model, column dimension reduction fusion is performed first, followed by row dimension reduction fusion, to obtain the second large language model. The column dimension reduction fusion includes: when the first difference between the number of rows in the first column transformation matrix corresponding to the first channel in the first network layer of the first large language model and the number of columns in the corresponding two-dimensional parameter matrix in the first large language model satisfies a first difference condition, the first column transformation matrix is ​​updated based on the ratio between the number of rows in the first column transformation matrix and a preset column receptive field value, so that the number of rows in the updated first column transformation matrix is ​​the ratio between the number of rows in the first column transformation matrix before the update and the preset column receptive field value; the updated first column transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform column dimension reduction parameter fusion; wherein the column receptive field value is greater than 1. Based on the three-dimensional parameter matrix of each network layer in the second language model, the network layer parameters in the second language model are fused to obtain the third language model. Based on the first and third language models, the target loss function is determined; If the target loss function satisfies the preset first function condition, the third large language model is trained based on text data to obtain the target large language model.

2. The method according to claim 1, wherein, The dimension fusion operator is decomposed into column transformation matrices and row transformation matrices. For each channel's two-dimensional parameter matrix in each network layer of the first large language model, column dimension reduction fusion is performed first, followed by row dimension reduction fusion, to obtain the second large language model, including: The dimension fusion operator is decomposed to obtain the column transformation matrix and row transformation matrix corresponding to each channel in each network layer of the first large language model; Based on the column transformation matrix corresponding to each channel in each network layer of the first large language model, the column dimension of the two-dimensional parameter matrix of each channel in each network layer of the first large language model is reduced and fused to obtain the fourth large language model. Based on the row transformation matrix corresponding to each channel in each network layer of the first large language model, the row dimension reduction parameter fusion is performed on the two-dimensional parameter matrix of each channel in each network of the fourth large language model to obtain the second large language model.

3. The method according to claim 2, wherein, The second language model is obtained by performing row-dimensionality reduction and parameter fusion on the two-dimensional parameter matrices of each channel in each network layer of the first language model, based on the row transformation matrix corresponding to each channel in each network of the fourth language model, to obtain the second language model, including: For the first row transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the second difference between the number of rows of the first row transformation matrix and the number of rows of the corresponding two-dimensional parameter matrix in the first large language model satisfies the second difference condition, the first row transformation matrix is ​​updated based on the ratio between the number of rows of the first row transformation matrix and the preset row receptive field value. The updated first row transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform dimensionality reduction parameter fusion in the row dimension. The receptive field value is greater than 1.

4. The method according to any one of claims 1-3, further comprising: If the target loss function does not satisfy the first function condition, the dimension fusion operator is adjusted based on the target loss function.

5. The method according to claim 1, wherein, The method involves fusing the parameters of the network layers in the second language model based on the three-dimensional parameter matrices of each network layer to obtain a third language model, including: Based on the layer fusion operator, the mapping coefficients from each network layer in the first model to each network layer in the second model are determined, wherein the number of network layers in the first model is the same as the number of network layers in the second large language model; For each second network layer in the second model, the three-dimensional parameter matrix of the second network layer is obtained based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients of each network layer in the first model to the second network layer. The third major language model is determined based on the three-dimensional parameter matrices of each of the second network layers.

6. The method according to claim 5, wherein, The method of obtaining the three-dimensional parameter matrix of the second network layer based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients from each network layer in the first model to the second network layer includes: The three-dimensional parameter matrices of each network layer in the second large language model are multiplied by the mapping coefficients from the corresponding network layer in the first model to the second network layer to obtain multiple three-dimensional parameter matrices. The summation of the multiple three-dimensional parameter matrices yields the three-dimensional parameter matrix of the second network layer.

7. The method according to any one of claims 5-6, further comprising: If the target loss function does not satisfy the first function condition, the layer fusion operator is adjusted based on the target loss function.

8. The method according to claim 1, wherein, The determination of the target loss function based on the first and third largest language models includes: Based on the first training sample set, determine the first loss function and the first output distribution of the first large language model; Based on the second training sample set, determine the second loss function and the second output distribution of the third language model; Based on the first output distribution and the second output distribution, determine the third loss function; The target loss function is obtained by weighted summation of the first loss function, the second loss function, and the third loss function.

9. A large language model training device, comprising: The dimension reduction parameter fusion module is used to decompose the dimension fusion operator into column transformation matrices and row transformation matrices. It performs column dimension reduction fusion and then row dimension reduction fusion on the two-dimensional parameter matrices of each channel in each network layer of the first large language model to obtain the second large language model. The column dimension reduction fusion includes: when the first difference between the number of rows in the first column transformation matrix corresponding to the first channel in the first network layer of the first large language model and the number of columns in the corresponding two-dimensional parameter matrix in the first large language model satisfies a first difference condition, the first column transformation matrix is ​​updated based on the ratio between the number of rows in the first column transformation matrix and a preset column receptive field value, so that the number of rows in the updated first column transformation matrix is ​​the ratio between the number of rows in the first column transformation matrix before the update and the preset column receptive field value; the updated first column transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform column dimension reduction parameter fusion; wherein the column receptive field value is greater than 1. The layer reduction parameter fusion module is used to perform layer reduction parameter fusion on the network layers in the second large language model based on the three-dimensional parameter matrix of each network layer in the second large language model to obtain the third large language model. The objective function determination module is used to determine the objective loss function based on the first large language model and the third large language model; The model training module is used to train the third large language model based on text data to obtain the target large language model, provided that the target loss function satisfies the preset first function condition.

10. The apparatus according to claim 9, wherein, The dimensionality reduction parameter fusion module includes: The operator decomposition unit is used to decompose the dimension fusion operator to obtain the column transformation matrix and row transformation matrix corresponding to each channel in each network layer of the first large language model; The column parameter fusion unit is used to perform dimensionality reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network layer of the first large language model based on the column transformation matrix corresponding to each channel in each network layer of the first large language model, so as to obtain the fourth large language model. The row parameter fusion unit is used to perform dimensionality reduction parameter fusion on the two-dimensional parameter matrix of each channel in each network of the fourth language model based on the row transformation matrix corresponding to each channel in each network layer of the first language model, so as to obtain the second language model.

11. The apparatus according to claim 10, wherein, The second language model is obtained by performing row-dimensionality reduction and parameter fusion on the two-dimensional parameter matrices of each channel in each network layer of the first language model, based on the row transformation matrix corresponding to each channel in each network of the fourth language model, to obtain the second language model, including: For the first row transformation matrix corresponding to the first channel in the first network layer of the first large language model, if the second difference between the number of rows of the first row transformation matrix and the number of rows of the corresponding two-dimensional parameter matrix in the first large language model satisfies the second difference condition, the first row transformation matrix is ​​updated based on the ratio between the number of rows of the first row transformation matrix and the preset row receptive field value. The updated first row transformation matrix is ​​multiplied by the corresponding two-dimensional parameter matrix in the first large language model to perform dimensionality reduction parameter fusion in the row dimension. The receptive field value is greater than 1.

12. The apparatus according to any one of claims 9-11, further comprising: The first operator adjustment module is used to adjust the dimension fusion operator based on the target loss function when the target loss function does not satisfy the first function condition.

13. The apparatus according to claim 9, wherein, The downsizing parameter fusion module includes: The mapping coefficient determination unit is used to determine the mapping coefficients from each network layer in the first model to each network layer in the second model based on the layer fusion operator, wherein the number of network layers in the first model is the same as the number of network layers in the second large language model; The mapping processing unit is used to obtain the three-dimensional parameter matrix of the second network layer for each second network layer in the second model, based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients of each network layer in the first model to the second network layer. The model determination unit is used to determine the third major language model based on the three-dimensional parameter matrix of each of the second network layers.

14. The apparatus according to claim 13, wherein, The method of obtaining the three-dimensional parameter matrix of the second network layer based on the three-dimensional parameter matrix of each network layer in the second large language model and the mapping coefficients from each network layer in the first model to the second network layer includes: The three-dimensional parameter matrices of each network layer in the second large language model are multiplied by the mapping coefficients from the corresponding network layer in the first model to the second network layer to obtain multiple three-dimensional parameter matrices. The summation of the multiple three-dimensional parameter matrices yields the three-dimensional parameter matrix of the second network layer.

15. The apparatus according to any one of claims 13-14, further comprising: The second operator adjustment module is used to adjust the layer fusion operator based on the target loss function when the target loss function does not meet the first function condition.

16. The apparatus according to claim 9, wherein, The objective function determination module includes: The first function determination unit is used to determine the first loss function and the first output distribution of the first large language model based on the first training sample set; The second function determination unit is used to determine the second loss function and the second output distribution of the third language model based on the second training sample set. The third function determination unit is used to determine a third loss function based on the first output distribution and the second output distribution; The objective function determination unit is used to perform a weighted summation of the first loss function, the second loss function, and the third loss function to obtain the objective loss function.

17. An electronic device comprising: At least one central processing unit; as well as A memory communicatively connected to the at least one central processing unit; wherein, The memory stores instructions executable by the at least one central processing unit (CPU) to enable the at least one CPU to perform the method of any one of claims 1-8.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-8.

19. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Model compression training method and device, electronic equipment and storage medium

    CN117808066A