Large model based text processing and large model compression method and device

By compressing large models and performing dynamic recursive calculations, the problem of high memory consumption when deploying large models on resource-constrained platforms is solved, achieving efficient operation and performance improvement.

CN120874936BActive Publication Date: 2026-07-03BEIJING BAIDU NETCOM SCI & TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING BAIDU NETCOM SCI & TECH CO LTD
Filing Date
2025-06-03
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

The large model parameters result in excessive memory consumption when deployed on resource-constrained platforms, making it difficult to run.

Method used

By compressing the large model, Lm sequentially adjacent candidate layers are selected and merged into a single fusion layer to reduce the parameter size. The input text is then processed using a dynamic recursive calculation method.

Benefits of technology

It reduces the GPU memory usage of large models during deployment, improves processing performance and efficiency, and is suitable for resource-constrained platforms such as PCs, mobile devices, and edge devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120874936B_ABST
    Figure CN120874936B_ABST
Patent Text Reader

Abstract

The present disclosure provides a large model-based text processing method and device and a large model compression method and device, and relates to the fields of deep learning, large models, natural language processing and the like. The large model-based text processing method can include: obtaining a word token sequence corresponding to an input text; and performing the following processing on each word token in the word token sequence: in response to determining that the word token needs to be processed by using a fusion layer in a target large model, generating a target processing result corresponding to the word token by performing inference calculation in the fusion layer at least twice, the target large model being obtained after model compression is performed on a to-be-compressed large model, the model compression including fusing Lm layers that are sequentially adjacent in the to-be-compressed large model into the fusion layer, Lm being a positive integer greater than 1 and smaller than L, L representing the number of layers included in the to-be-compressed large model.
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, particularly to the fields of deep learning, large models and natural language processing, and especially to methods and apparatus for text processing and compression based on large models. Background Technology

[0002] Large Language Models (LLMs) are deep learning models trained on large amounts of text data that can generate natural language text or understand the meaning of language text. Furthermore, reinforcement learning can activate the long-chain reasoning capabilities of large models, making them suitable for various simple and complex reasoning tasks. Summary of the Invention

[0003] This disclosure provides a method and apparatus for text processing and compression based on large models.

[0004] A text processing method based on a large model includes:

[0005] Obtain the word sequence corresponding to the input text;

[0006] For each word in the word sequence, the following processing is performed: In response to determining that the word needs to be processed using the fusion layer in the target large model, the target processing result corresponding to the word is generated by executing the inference calculation in the fusion layer at least twice. The target large model is obtained by compressing the large model to be compressed. The model compression includes fusing Lm consecutively adjacent layers in the large model to be compressed into the fusion layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of layers included in the large model to be compressed.

[0007] A large model compression method includes:

[0008] Obtain the large model to be compressed, and determine each layer in it as a candidate layer;

[0009] According to the predetermined screening criteria, Lm consecutive target layers are selected from each candidate layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of candidate layers included in the large model to be compressed.

[0010] The target layers are merged into a single fusion layer to obtain the large target model as the compression result.

[0011] A text processing device based on a large model includes: an acquisition module and a processing module;

[0012] The acquisition module is used to acquire the word sequence corresponding to the input text;

[0013] The processing module is configured to perform the following processing on each word in the word sequence: in response to determining that the word needs to be processed using the fusion layer in the target large model, the module generates the target processing result corresponding to the word by executing the inference calculation in the fusion layer at least twice. The target large model is obtained by compressing the large model to be compressed. The model compression includes fusing Lm consecutively adjacent layers in the large model to be compressed into the fusion layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of layers included in the large model to be compressed.

[0014] A large model compression device includes: a preprocessing module, a screening module, and a compression module;

[0015] The preprocessing module is used to obtain the large model to be compressed and determine each layer in it as a candidate layer.

[0016] The filtering module is used to filter out Lm sequentially adjacent target layers from each candidate layer according to predetermined filtering conditions, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of candidate layers included in the large model to be compressed.

[0017] The compression module is used to merge each target layer into a fusion layer to obtain the target large model as the compression result.

[0018] An electronic device, comprising:

[0019] At least one processor; and

[0020] A memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described above.

[0022] A non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the methods described above.

[0023] A computer program product includes a computer program / instructions that, when executed by a processor, implement the method described above.

[0024] 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

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

[0026] Figure 1 This is a flowchart of an embodiment of the large model compression method described in this disclosure;

[0027] Figure 2 This is a schematic diagram of the submatrix described in this disclosure;

[0028] Figure 3 This is a schematic diagram of the large model to be compressed and the target large model as described in this disclosure;

[0029] Figure 4 A flowchart illustrating an embodiment of the large-model-based text processing method described in this disclosure;

[0030] Figure 5 This is a schematic diagram of the composition structure of Embodiment 500 of the large model compression device described in this disclosure;

[0031] Figure 6 This is a schematic diagram of the composition structure of Embodiment 600 of the text processing device based on a large model as described in this disclosure;

[0032] Figure 7 A schematic block diagram of an electronic device 700 that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation

[0033] 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 and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0034] Furthermore, it should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0035] Currently, although large models have been widely used in different scenarios, they also have certain problems. For example, large models have a huge number of parameters, and all parameters need to be loaded during deployment, which will significantly increase the memory usage of graphics processing units (GPUs) or artificial intelligence (AI) accelerators, making it difficult for large models to run on resource-constrained platforms.

[0036] To address this, the present disclosure proposes a large model compression method. By compressing the large model, the parameter size of the large model can be reduced, thereby reducing the GPU memory usage of the large model during deployment. This allows the large model to run on resource-constrained platforms such as personal computers, mobile devices, edge devices, and wearable devices.

[0037] Based on this, the scheme described in this disclosure also proposes a text processing method based on a large model. That is, when processing the token sequence corresponding to the input text using the compressed target large model, a dynamic recursive calculation method can be adopted to improve the processing performance and efficiency of the target large model.

[0038] The two methods described above will be explained in detail below.

[0039] Figure 1 This is a flowchart illustrating an embodiment of the large model compression method described in this disclosure. Figure 1 As shown, the specific implementation methods are as follows.

[0040] In step 101, the large model to be compressed is obtained, and each layer in it is determined as a candidate layer.

[0041] In step 102, according to the predetermined screening conditions, Lm consecutive target layers are selected from each candidate layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of candidate layers included in the large model to be compressed.

[0042] In step 103, the target layers are merged into a single fusion layer to obtain the large target model as the compression result.

[0043] As can be seen, by adopting the scheme described in the above method embodiment, the compression processing of the large model to be compressed can be achieved by merging the selected Lm sequentially adjacent target layers into a fusion layer, thereby reducing the parameter scale of the large model and thus reducing the memory usage of the large model during deployment.

[0044] The specific type of large model to be compressed is not limited and can be determined according to actual needs. In addition, for ease of distinction, each layer in the large model to be compressed is called a candidate layer, and each selected layer is called a target layer.

[0045] Among them, Lm sequentially adjacent target layers can be selected from each candidate layer according to the predetermined screening conditions. The specific value of Lm can be determined according to actual needs. For example, it can be an empirical value or a value determined after a series of pre-experiments to search for hyperparameters.

[0046] In some embodiments of this disclosure, an L*L similarity matrix can be generated, wherein the element S located in the i-th row and j-th column of the similarity matrix is... ij This is used to represent the parameter similarity between the i-th candidate layer and the j-th candidate layer, where 1≤i≤L and 1≤j≤L. Then, each target layer can be determined based on the similarity matrix.

[0047] In other words, for each candidate layer, the parameter similarity between that candidate layer and all other layers, as well as itself, can be obtained. Assuming L is 10, then taking candidate layer 1 as an example, the parameter similarity between candidate layer 1 and candidate layers 1 through 10 can be obtained. Accordingly, a similarity matrix can be constructed based on all the obtained parameter similarities.

[0048] In some embodiments of this disclosure, the element S in the similarity matrix ij The acquisition method may include: obtaining the distribution of cosine similarity (DOCS) values ​​between each parameter matrix in the i-th candidate layer and the parameter matrix of the same type in the j-th candidate layer, where the number and type of parameter matrices are the same in different candidate layers. Then, S can be determined based on each DOCS value. ij .

[0049] To measure the parameter similarity between candidate layers, the scheme described in this disclosure uses the DOCS value as an evaluation index to improve the accuracy of the obtained parameter similarity. The DOCS value is an index specifically designed to measure the similarity of neural network weights. This index has a strong ability to distinguish parameter matrices that exhibit orthogonality. The larger the DOCS value between two parameter matrices, the higher the degree of similarity between the two parameter matrices.

[0050] For any two candidate layers, the parameter similarity between the two candidate layers can be conveniently and accurately determined based on the corresponding parameter matrices in the two candidate layers. Accordingly, a similarity matrix can be quickly and accurately constructed, thus laying a good foundation for subsequent target layer determination, etc.

[0051] For example, given any two parameter matrices X and Y, The calculation process for the DOCS values ​​of the two parameter matrices is as follows.

[0052] First, construct the cosine similarity matrix. Each element C j'k Let represent the cosine similarity between the j'th column of parameter matrix X and the kth column of parameter matrix Y, respectively, where 1≤j'≤m and 1≤k≤m.

[0053] Next, for each column of the parameter matrix X, the following processing can be performed: select the maximum value from the cosine similarity between that column and each column of the parameter matrix Y. In this way, the maximum values ​​corresponding to each column of the parameter matrix X can be obtained. Then, the maximum values ​​corresponding to each column can be arranged in order (the earlier the corresponding column, the earlier it is sorted), thus obtaining the similarity vector S. X Similarly, the similarity vector S can be obtained. Y For each column of the parameter matrix Y, the following processing can be performed: select the maximum value from the cosine similarity between that column and each column of the parameter matrix X. This yields the maximum value for each column in the parameter matrix Y. Then, the maximum values ​​for each column can be arranged sequentially to obtain the similarity vector S. Y .

[0054] Similarity vector S X and S Y This represents the maximum similarity between the column vector groups of two parameter matrices. The Gumbel distribution can then be used to model the distribution of the two similarity vectors, and the position parameter μ can be calculated using maximum likelihood estimation based on the modeling results. X and μ Y To describe the central tendency of the similarity distribution, μ can be further... X and μ Y The mean value is determined as the required DOCS value.

[0055] Additionally, in some embodiments of this disclosure, the large model to be compressed may include: a large model employing a Transformer architecture, wherein the parameter matrix in each candidate layer may include: the first parameter matrix (W) corresponding to the attention module. v The second parameter matrix (Wk) corresponding to the attention module, and the third parameter matrix (Wk) corresponding to the attention module. q ), the fourth parameter matrix (W) corresponding to the attention module o The fifth parameter matrix corresponding to the Multilayer Perceptron (MLP) module.

[0056] The Transformer architecture employs an attention-based structure, enabling large models to be parallelized, thereby improving computational efficiency and solving many problems of traditional neural networks such as forgetfulness and slow training speed. In large models using the Transformer architecture, some adjacent layers exhibit high similarity, making them more suitable for the model compression method described in this disclosure.

[0057] Each candidate layer typically includes an attention module and a multilayer perceptron module. The attention module usually corresponds to four parameter matrices, while the multilayer perceptron module usually corresponds to one parameter matrix, which can also be called a weight matrix.

[0058] Accordingly, in some embodiments of this disclosure, for the i-th candidate layer and the j-th candidate layer, the first DOCS value between the first parameter matrices in the two candidate layers, the second DOCS value between the second parameter matrices in the two candidate layers, the third DOCS value between the third parameter matrices in the two candidate layers, the fourth DOCS value between the fourth parameter matrices in the two candidate layers, and the fifth DOCS value between the fifth parameter matrices in the two candidate layers can be obtained respectively.

[0059] After obtaining the first, second, third, fourth, and fifth DOCS values ​​respectively, S can be further determined based on each DOCS value. ij .

[0060] In some embodiments of this disclosure, the products of the first DOCS value and the first coefficient, the second DOCS value and the second coefficient, the third DOCS value and the third coefficient, the fourth DOCS value and the fourth coefficient, and the fifth DOCS value and the fifth coefficient can be obtained respectively. The sum of these products is then obtained to obtain a first intermediate result. The first coefficient represents the number of parameters included in the first parameter matrix, the second coefficient represents the number of parameters included in the second parameter matrix, the third coefficient represents the number of parameters included in the third parameter matrix, the fourth coefficient represents the number of parameters included in the fourth parameter matrix, and the fifth coefficient represents the number of parameters included in the fifth parameter matrix. The sum of the first, second, third, fourth, and fifth coefficients is then obtained to obtain a second intermediate result. The ratio of the first intermediate result to the second intermediate result can then be determined as S. ij .

[0061] That is:

[0062]

[0063] Among them, W i Attn1 W represents the first parameter matrix in the i-th candidate layer. j Attn1 W represents the first parameter matrix in the j-th candidate layer. i Attn2 W represents the second parameter matrix in the i-th candidate layer. j Attn2 W represents the second parameter matrix in the j-th candidate layer. i Attn3W represents the third parameter matrix in the i-th candidate layer. j Attn3 W represents the third parameter matrix in the j-th candidate layer. i Attn4 W represents the fourth parameter matrix in the i-th candidate layer. j Attn4 W represents the fourth parameter matrix in the j-th candidate layer. i MLP W represents the fifth parameter matrix in the i-th candidate layer. j MLP Let DOCS(W) represent the fifth parameter matrix in the j-th candidate layer, where b represents the first coefficient, c represents the second coefficient, d represents the third coefficient, e represents the fourth coefficient, and a represents the fifth coefficient. i Attn1 W j Attn1 ) represents the first DOCS value, DOCS(W i Attn2 W j Attn2 ) represents the second DOCS value, DOCS(W i Attn3 W j Attn3 ) represents the third DOCS value, DOCS(W i Attn4 W j Attn4 ) represents the fourth DOCS value, DOCS(W i MLP W j MLP ) indicates the fifth DOCS value.

[0064] In other words, the DOCS values ​​between the parameter matrices of the i-th candidate layer and the corresponding parameter matrices of the j-th candidate layer can be obtained respectively. Based on these DOCS values, the global inter-layer similarity between the i-th and j-th candidate layers can be determined through aggregation and other operations, i.e., S. ij Because it simultaneously incorporates DOCS values ​​from different types of parameter matrices to calculate S ij Therefore, the obtained S was increased. ij Accuracy, etc.

[0065] Based on the constructed similarity matrix, each target layer can be determined. Experiments have shown that within a large model, there may be multiple adjacent layers whose parameters exhibit high similarity, meaning that the parameter similarity between these layers is generally higher than the parameter similarity between other layers. Based on this experimental observation, the scheme described in this disclosure proposes to fuse adjacent layers with high similarity to reduce the redundancy of parameters within the large model.

[0066] In some embodiments of this disclosure, the elements located on the main diagonal of the similarity matrix can be determined as target elements, and for each target element, the following processing can be performed: in response to being able to extract an Lm*Lm submatrix from the similarity matrix with the target element as the top left vertex, the norm value of the submatrix is ​​determined according to a predetermined norm algorithm, and the maximum value is selected from the obtained norm values, and the candidate layer corresponding to the submatrix corresponding to the maximum value is determined as the desired target layer.

[0067] Figure 2 This is a schematic diagram of the submatrix described in this disclosure. For example... Figure 2 As shown, each small black dot represents an element in the similarity matrix. Assuming Lm is 4, taking the target element located in the 2nd row and 2nd column of the similarity matrix as an example, we can extract... Figure 2 The submatrix shown.

[0068] As one possible implementation, for each submatrix, its Frobenius norm value can be obtained separately. Then, the maximum value can be selected from all the obtained norm values, assuming that the submatrix corresponding to the maximum value is... Figure 2 If the submatrix shown is used, then each candidate layer (i.e., candidate layer 2 to candidate layer 5) corresponding to the submatrix can be determined as the target layer.

[0069] As can be seen, by using the above processing method, the target layer can be efficiently and accurately selected from each candidate layer by simply using submatrix truncation and norm value calculation.

[0070] Then, the target layers can be merged into a single fusion layer to obtain the large target model as the compression result.

[0071] In some embodiments of this disclosure, the following processing can be performed on different types of parameter matrices: the mean value of the parameter matrix of the type in each target layer can be obtained, and then the obtained mean value can be determined as the parameter matrix in the fusion layer to obtain the fusion layer.

[0072] That is:

[0073]

[0074] in, Let Lm represent a parameter matrix of a certain type in each target layer. The sum of the parameter matrices of that type in each target layer can be obtained (element-by-element calculation). Then, the sum can be divided by Lm (element-by-element calculation) to obtain the mean W of the parameter matrices of that type in each target layer. new W newThis refers to the parameter matrix of the type described in the fusion layer.

[0075] Specifically, assuming there are 4 target layers, the mean of the first parameter matrix, the mean of the second parameter matrix, the mean of the third parameter matrix, the mean of the fourth parameter matrix, and the mean of the fifth parameter matrix in the 4 target layers can be obtained respectively, thereby obtaining the first parameter matrix, the second parameter matrix, the third parameter matrix, the fourth parameter matrix, and the fifth parameter matrix in the fusion layer.

[0076] Through the above processing, the model parameters can be fused and compressed. The degree of compression can be controlled by adjusting the hyperparameter Lm. The larger the value of Lm, the more layers are fused and compressed, but it is also easy to cause over-compression, which will fuse some non-redundant layers and cause excessive performance loss. Therefore, it is necessary to set the value of Lm reasonably. In practical applications, the value of Lm can be determined by a series of pre-experiments to search for hyperparameters, that is, to find the optimal degree of compression that will not cause performance collapse.

[0077] In summary, by adopting the model compression method described in this disclosure, the redundancy of parameters between layers within a large model can be utilized. Through operations such as similarity measurement and parameter fusion, the number of model layers can be reduced, thereby reducing the parameter scale of the large model. This, in turn, reduces the GPU memory usage during deployment and improves the running speed.

[0078] Figure 3 This is a schematic diagram of the large model to be compressed and the target large model as described in this disclosure. Figure 3 As shown, assuming that the large model to be compressed includes 8 candidate layers, namely candidate layer 1 to candidate layer 8, and assuming that candidate layer 3, candidate layer 4, candidate layer 5 and candidate layer 6 are selected as the target layer, then candidate layer 3, candidate layer 4, candidate layer 5 and candidate layer 6 can be fused into a fusion layer to obtain the desired target large model.

[0079] The present disclosure also proposes the application / usage method of the target large model, which will be described in detail below through embodiments.

[0080] Figure 4 This is a flowchart illustrating an embodiment of the large-model-based text processing method described in this disclosure. Figure 4 As shown, the specific implementation methods are as follows.

[0081] In step 401, the word sequence corresponding to the input text is obtained.

[0082] In step 402, for each word in the word sequence, the following processing is performed: In response to determining that the word needs to be processed using the fusion layer in the target large model, the target processing result corresponding to the word is generated by executing the inference calculation in the fusion layer at least twice. The target large model is obtained by compressing the large model to be compressed. The model compression includes fusing Lm sequentially adjacent layers in the large model to be compressed into the fusion layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of layers included in the large model to be compressed.

[0083] Compression of large models reduces the number of layers, potentially decreasing their representational power and performance. To compensate for this performance loss, this disclosure proposes a multi-loop computation approach. Physically, only one layer (fusion layer) of parameters is retained, but the data flow passes through this layer multiple times, logically expanding it into multiple layers. This reduces the size of the large model's parameters while maintaining its effective depth. In other words, loop computation compensates for the reduced representational power of the large model due to the reduced number of layers, thereby improving its performance.

[0084] This architecture also gives large models another advantage: the number of loop calculations can be adaptively adjusted according to the difficulty of the task, that is, a dynamic recursive calculation method can be adopted.

[0085] In practical applications, the target large model can process each word in a word sequence in a predetermined order. For the fusion layer, different number of loop calculations can be used for different words, meaning that more loop calculations can be automatically performed at key points on the inference path.

[0086] Accordingly, in some embodiments of this disclosure, for each lexical unit, the original input corresponding to the fusion layer can be determined, and the fusion layer can be used to perform inference calculations on the original input. Then, the following predetermined processing can be performed: the fusion layer is used to perform inference calculations on the most recently obtained calculation result, and the most recently obtained calculation result is determined as a candidate result, and the most recently obtained calculation result before the candidate result is determined as a reference result; in response to determining that the termination condition is met based on the candidate result and the reference result, the candidate result can be determined as the target processing result; in response to determining that the termination condition is not met, the predetermined processing can be repeated.

[0087] Taking a word 'a' in the word sequence as an example, for the other layers in the target large model other than the fusion layer, word 'a' can be processed in the traditional way. When it is necessary to use the fusion layer to process word 'a', the inference calculation in the fusion layer needs to be executed at least twice. Specifically, the original input corresponding to word 'a' can be obtained first, such as using the calculation result 0 corresponding to word 'a' generated by the previous layer of the fusion layer. Then, the fusion layer can be used to perform inference calculation on the original input to obtain calculation result 1. Further, the fusion layer can be used to perform inference calculation on calculation result 1 to obtain calculation result 2. Calculation result 2 can be determined as a candidate result, and calculation result 1 can be determined as a reference result. Then, based on the candidate result and the reference result, it can be determined whether the termination condition is met. If not, the fusion layer can be used to perform inference calculation on calculation result 2 to obtain calculation result 3. Calculation result 3 can be determined as a candidate result, and calculation result 2 can be determined as a reference result. Then, based on the candidate result and the reference result, it can be determined whether the termination condition is met. If so, the candidate result, i.e., calculation result 3, can be determined as the required target processing result.

[0088] The iterative calculation process can be represented as follows:

[0089] x t =f(x) t-1 ;θ Layer (3)

[0090] Where f represents the inference computation performed in the fusion layer, θ Layer x represents all parameters in the fusion layer. t-1 x represents the result of the previous inference calculation. t This represents the result of the most recent inference calculation.

[0091] Through the above processing, the number of iterations corresponding to different lexical units can be automatically determined. This allows the target large model to be optimized into a large model with variable depth, which can adaptively adjust the effective depth of the target large model according to the difficulty of the task. For simple lexical processing tasks, not only is redundant computation reduced through model compression, but the number of iterations can also be reduced, thereby improving processing efficiency, reducing latency, and improving resource utilization. For complex lexical processing tasks, the number of iterations can be increased to simulate a deeper large model, thereby improving the accuracy of the processing results.

[0092] In some embodiments of this disclosure, when determining whether the termination condition is met based on the candidate results and the reference results, the latent semantic saturation (LSS) can be determined first based on the candidate results and the reference results. Then, the LSS can be compared with a predetermined threshold. In response to determining that the LSS is greater than the threshold, it can be determined that the termination condition is met.

[0093] The LSS can be used as the loop stopping index. Once it is determined that the obtained LSS is greater than the threshold, the loop can be terminated, and the most recently obtained calculation result can be determined as the target processing result.

[0094] In some embodiments of this disclosure, the method for determining the LSS based on the candidate result and the reference result may include: transposing the candidate result and obtaining a first product of the transposed result and the reference result, obtaining a second product of the modulus of the candidate result and the modulus of the reference result, and determining the ratio of the first product and the second product as the LSS.

[0095] That is:

[0096]

[0097] Where, x t x represents the candidate result. t-1 Indicates a reference result.

[0098] LSS measures the cosine similarity between the results of two adjacent inference calculations. If LSS is less than or equal to the threshold, it means that the latent representation (calculation result) obtained after the most recent inference calculation has changed significantly compared to the previous one, and there is still room for optimization and deduction of the latent vector. Therefore, the next inference calculation can continue. If LSS is greater than the threshold, it means that the impact of the loop calculation on the latent vector has become saturated, and the current latent vector already contains enough information for the inference calculation of subsequent layers. Therefore, the loop calculation can be stopped, and the calculation result obtained most recently can be sent to the subsequent layers for processing.

[0099] The specific value of the threshold can be determined according to actual needs. For example, it can be an empirical value, or a value determined after a series of preliminary experiments to search for hyperparameters.

[0100] In some embodiments of this disclosure, in response to determining, based on candidate results and reference results, that a result does not meet the termination condition but has been determined to have undergone T inference calculations using the fusion layer, the candidate result can be determined as the target processing result, where T is a positive integer greater than 2.

[0101] A maximum number of loop calculations T can be set. Once this value is reached, the loop can be forcibly terminated even if the termination condition is not met, and the latest candidate result can be directly determined as the target processing result, thereby avoiding problems such as excessive latency caused by too many loop calculations.

[0102] The text processing method based on large models described in this disclosure can be further illustrated by the following example: Suppose a user sends... Figure 3 The target large model shown is given a text as input. The word sequence corresponding to the text can be obtained. Then, each word in the word sequence can be processed in turn. For any word, it can be processed in the order of candidate layer 1, candidate layer 2, fusion layer, candidate layer 7, and candidate layer 8. The processing methods of candidate layer 1, candidate layer 2, candidate layer 7, and candidate layer 8 are the same as the traditional method, that is, based on the input content, the output calculation result is generated through inference calculation. For the fusion layer, the loop calculation method in the scheme described in this disclosure can be used to obtain the desired target processing result.

[0103] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this disclosure. Secondly, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this disclosure. Furthermore, for parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0104] The above is an introduction to the method embodiments. The following describes the solution described in this disclosure further through device embodiments.

[0105] Figure 5 This is a schematic diagram of the structural composition of Embodiment 500 of the large model compression device described in this disclosure. Figure 5 As shown, it includes: a preprocessing module 501, a filtering module 502, and a compression module 503.

[0106] The preprocessing module 501 is used to obtain the large model to be compressed and to determine each layer in it as a candidate layer.

[0107] The filtering module 502 is used to filter out Lm sequentially adjacent target layers from each candidate layer according to predetermined filtering conditions. Lm is a positive integer greater than 1 and Lm is less than L, where L represents the number of candidate layers included in the large model to be compressed.

[0108] Compression module 503 is used to merge the target layers into a single fusion layer to obtain the large target model as the compression result.

[0109] In some embodiments of this disclosure, the filtering module 502 can generate an L*L similarity matrix, wherein the element S located in the i-th row and j-th column of the similarity matrix is... ij This is used to represent the parameter similarity between the i-th candidate layer and the j-th candidate layer, where 1≤i≤L and 1≤j≤L. Then, each target layer can be determined based on the similarity matrix.

[0110] In some embodiments of this disclosure, the filtering module 502 acquires S ij The method may include: obtaining the DOCS values ​​between each parameter matrix in the i-th candidate layer and the parameter matrix of the same type in the j-th candidate layer, where different candidate layers include the same number and type of parameter matrices, and then determining S based on each DOCS value. ij .

[0111] In some embodiments of this disclosure, the large model to be compressed may include: a large model using a Transformer architecture, wherein the parameter matrices in each candidate layer may include: a first parameter matrix corresponding to the attention module, a second parameter matrix corresponding to the attention module, a third parameter matrix corresponding to the attention module, a fourth parameter matrix corresponding to the attention module, and a fifth parameter matrix corresponding to the multilayer perceptron module; accordingly, for the i-th candidate layer and the j-th candidate layer, the filtering module 502 may respectively obtain the first DOCS value between the first parameter matrices in the two candidate layers, the second DOCS value between the second parameter matrices in the two candidate layers, the third DOCS value between the third parameter matrices in the two candidate layers, the fourth DOCS value between the fourth parameter matrices in the two candidate layers, and the fifth DOCS value between the fifth parameter matrices in the two candidate layers.

[0112] After obtaining the first DOCS value, the second DOCS value, the third DOCS value, the fourth DOCS value, and the fifth DOCS value respectively, the filtering module 502 can further determine S based on each DOCS value. ij .

[0113] In some embodiments of this disclosure, the filtering module 502 can obtain the product of the first DOCS value and the first coefficient, the product of the second DOCS value and the second coefficient, the product of the third DOCS value and the third coefficient, the product of the fourth DOCS value and the fourth coefficient, and the product of the fifth DOCS value and the fifth coefficient, respectively, and can obtain the sum of each product to obtain a first intermediate result. The first coefficient represents the number of parameters included in the first parameter matrix, the second coefficient represents the number of parameters included in the second parameter matrix, the third coefficient represents the number of parameters included in the third parameter matrix, the fourth coefficient represents the number of parameters included in the fourth parameter matrix, and the fifth coefficient represents the number of parameters included in the fifth parameter matrix. The module can also obtain the sum of the first, second, third, fourth, and fifth coefficients to obtain a second intermediate result. Furthermore, the ratio of the first intermediate result to the second intermediate result can be determined as S. ij .

[0114] Based on the constructed similarity matrix, each target layer can be determined. In some embodiments of this disclosure, the filtering module 502 can determine the elements located on the main diagonal of the similarity matrix as target elements, and can perform the following processing for each target element: in response to being able to extract an Lm*Lm submatrix from the similarity matrix with the target element as the top left vertex, the norm value of the submatrix is ​​determined according to a predetermined norm algorithm, and the maximum value is selected from the obtained norm values, and the candidate layer corresponding to the submatrix corresponding to the maximum value is determined as the desired target layer.

[0115] Subsequently, the compression module 503 can fuse the target layers into a single fusion layer, thereby obtaining the target large model as the compression result. In some embodiments of this disclosure, the compression module 503 can perform the following processing for different types of parameter matrices: obtain the mean value of the parameter matrices of the type in each target layer, and then determine the obtained mean values ​​as the parameter matrices in the fusion layer, thereby obtaining the fusion layer.

[0116] Figure 6 This is a schematic diagram of the structural composition of Embodiment 600 of the text processing device based on a large model as described in this disclosure. Figure 6 As shown, there are acquisition module 601 and processing module 602.

[0117] The acquisition module 601 is used to acquire the word sequence corresponding to the input text.

[0118] The processing module 602 is used to perform the following processing on each word in the word sequence: in response to determining that the word needs to be processed by the fusion layer in the target large model, the target processing result corresponding to the word is generated by executing the inference calculation in the fusion layer at least twice. The target large model is obtained by compressing the large model to be compressed. The model compression includes fusing Lm consecutively adjacent layers in the large model to be compressed into the fusion layer, where Lm is a positive integer greater than 1 and Lm is less than L, and L represents the number of layers included in the large model to be compressed.

[0119] In some embodiments of this disclosure, the processing module 602 can determine the original input of the fusion layer corresponding to each word, and can use the fusion layer to perform inference calculation on the original input. Then, the following predetermined processing can be performed: the fusion layer is used to perform inference calculation on the most recently obtained calculation result, and the most recently obtained calculation result is determined as a candidate result, and the most recently obtained calculation result before the candidate result is determined as a reference result; in response to determining that the termination condition is met based on the candidate result and the reference result, the candidate result can be determined as the target processing result; in response to determining that the termination condition is not met, the predetermined processing can be repeated.

[0120] In some embodiments of this disclosure, when the processing module 602 determines whether the termination condition is met based on the candidate results and the reference results, it can first determine the LSS based on the candidate results and the reference results, and then compare the LSS with a predetermined threshold. In response to determining that the LSS is greater than the threshold, it can be determined that the termination condition is met.

[0121] In some embodiments of this disclosure, the processing module 602 may determine the LSS based on the candidate result and the reference result by: transposing the candidate result and obtaining a first product of the transposed result and the reference result, obtaining a second product of the modulus of the candidate result and the modulus of the reference result, and determining the ratio of the first product and the second product as the LSS.

[0122] In addition, in some embodiments of this disclosure, the processing module 602, in response to determining that the candidate result does not meet the termination condition based on the candidate result and the reference result, but having determined that T inference calculations have been performed using the fusion layer, can determine the candidate result as the target processing result, where T is a positive integer greater than 2.

[0123] The specific workflow of each of the above device embodiments can be found in the relevant descriptions in the foregoing method embodiments, and will not be repeated here.

[0124] In summary, the scheme described in this disclosure combines model compression with dynamic recursive computation, which not only reduces the parameter size and computational redundancy of the target large model, but also improves the processing efficiency and resource utilization of the target large model, and enhances the accuracy of the processing results of the target large model. Moreover, compared with traditional large models with internal parameter redundancy and fixed depth, the target large model can exhibit strong flexibility and scalability, thereby meeting the usage needs of different scenarios.

[0125] The solutions described in this disclosure can be applied to the field of artificial intelligence, particularly deep learning, large-scale models, and natural language processing. Artificial intelligence is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It involves both hardware and software technologies. Artificial intelligence hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. Artificial intelligence software technologies mainly include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.

[0126] Furthermore, the text and other information in the embodiments described in this disclosure are not targeted at any specific user and do not reflect the personal information of any specific user. The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solutions of this disclosure all comply with relevant laws and regulations and do not violate public order and good morals.

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

[0128] Figure 7 A schematic block diagram of an electronic device 700 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, 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.

[0129] like Figure 7As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. The RAM 703 may also store various programs and data required for the operation of the electronic device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

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

[0131] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 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, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as those described in this disclosure. For example, in some embodiments, the methods described in this disclosure can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the methods described in this disclosure can be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the methods described herein by any other suitable means (e.g., by means of firmware).

[0132] 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 parts (ASSPs), systems-on-chip (SoCs), complex 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.

[0133] 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.

[0134] 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, read-only memory, erasable programmable read-only memory (EPROM), flash memory, optical fiber, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0135] 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 cathode ray tube (CRT) or liquid crystal display (LCD) 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).

[0136] 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 implementations 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 (e.g., a communication network) of any form or medium. Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0137] 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.

[0138] 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.

[0139] 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 spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A text processing method based on a large model, comprising: Obtain the word sequence corresponding to the input text; For each word in the word sequence, the following processing is performed: In response to the determination that the word needs to be processed by the fusion layer in the target large model, the original input of the fusion layer corresponding to the word is determined, the fusion layer is used to perform inference calculation on the original input, and the following predetermined processing is performed: the fusion layer is used to perform inference calculation on the most recently obtained calculation result, and the most recently obtained calculation result is determined as a candidate result, and the most recently obtained calculation result before the candidate result is determined as a reference result; In response to determining that the termination condition is met based on the candidate result and the reference result, the candidate result is determined as the target processing result; in response to determining that the termination condition is not met, the predetermined processing is repeated. The target large model is obtained by fusing Lm consecutively adjacent target layers in the large model to be compressed into a fusion layer, where 1 < Lm < L, and L represents the number of layers in the large model to be compressed. The target layer is determined by identifying the elements located on the main diagonal of the similarity matrix as target elements. For each target element, in response to the ability to extract an Lm*Lm submatrix with the target element as the top left vertex from the similarity matrix, the norm value of the submatrix is ​​determined according to a predetermined norm algorithm, and the candidate layer corresponding to the submatrix with the maximum value is selected from the obtained norm values. Each layer in the large model to be compressed is used as a candidate layer. The similarity matrix is ​​L*L in size, where the element Sij located in the i-th row and j-th column is used to represent the parameter similarity between the i-th candidate layer and the j-th candidate layer, where 1 ≤ i ≤ L and 1 ≤ j ≤ L.

2. The method of claim 1, wherein, The step of determining the termination condition based on the candidate results and the reference results includes: The latent semantic saturation is determined based on the candidate results and the reference results; In response to determining that the latent semantic saturation is greater than a predetermined threshold, the termination condition is determined to be met.

3. The method according to claim 2, wherein, Determining the latent semantic saturation based on the candidate results and the reference results includes: The candidate result is transposed, and the first product of the transposed result and the reference result is obtained. Obtain the second product of the modulus of the candidate result and the modulus of the reference result; The ratio of the first product to the second product is determined as the latent semantic saturation.

4. The method according to claim 1, further comprising: In response to determining, based on the candidate result and the reference result, that the termination condition is not met, but it is determined that T inference calculations have been performed using the fusion layer, the candidate result is determined as the target processing result, where T is a positive integer greater than 2.

5. A method for compressing large models, comprising: Obtain the large model to be compressed, and determine each layer in it as a candidate layer; According to predetermined screening criteria, Lm consecutively adjacent target layers are selected from each candidate layer, including: generating an L*L similarity matrix, where the element Sij in the i-th row and j-th column represents the parameter similarity between the i-th and j-th candidate layers, 1≤i≤L, 1≤j≤L, 1<Lm<L, and L represents the number of candidate layers included in the large model to be compressed; determining the elements on the main diagonal of the similarity matrix as target elements; for each target element, in response to the ability to extract an Lm*Lm submatrix with the target element as the top-left vertex from the similarity matrix, determining the norm value of the submatrix according to a predetermined norm algorithm; selecting the maximum value from the obtained norm values, and determining the candidate layer corresponding to the submatrix corresponding to the maximum value as the target layer; Each target layer is merged into a single fusion layer to obtain a large target model as the compression result. This model is used to process each word in the word sequence corresponding to the input text as follows: In response to determining that the word needs to be processed using the fusion layer in the large target model, the original input of the word corresponding to the fusion layer is determined. The fusion layer is used to perform inference calculations on the original input, and the following predetermined processing is executed: The fusion layer is used to perform inference calculations on the most recently obtained calculation result, and the most recently obtained calculation result is determined as a candidate result. The most recently obtained calculation result before the candidate result is determined as a reference result. In response to determining that the termination condition is met based on the candidate result and the reference result, the candidate result is determined as the target processing result. In response to determining that the termination condition is not met, the predetermined processing is repeated.

6. The method according to claim 5, wherein, The methods for obtaining Sij include: Obtain the cosine similarity distribution values ​​between each parameter matrix in the i-th candidate layer and the parameter matrix of the same type in the j-th candidate layer, wherein the number and type of parameter matrices included in different candidate layers are the same; The Sij is determined based on the distribution values ​​of each cosine similarity.

7. The method according to claim 6, wherein, The parameter matrices in each candidate layer include: the first parameter matrix corresponding to the attention module, the second parameter matrix corresponding to the attention module, the third parameter matrix corresponding to the attention module, the fourth parameter matrix corresponding to the attention module, and the fifth parameter matrix corresponding to the multilayer perceptron module; The step of obtaining the cosine similarity distribution values ​​between each parameter matrix in the i-th candidate layer and the parameter matrix of the same type in the j-th candidate layer includes: obtaining the first cosine similarity distribution value between the first parameter matrices in the two candidate layers, the second cosine similarity distribution value between the second parameter matrices in the two candidate layers, the third cosine similarity distribution value between the third parameter matrices in the two candidate layers, the fourth cosine similarity distribution value between the fourth parameter matrices in the two candidate layers, and the fifth cosine similarity distribution value between the fifth parameter matrices in the two candidate layers.

8. The method according to claim 7, wherein, The step of determining Sij based on each cosine similarity distribution value includes: The products of the first cosine similarity distribution value and the first coefficient, the second cosine similarity distribution value and the second coefficient, the third cosine similarity distribution value and the third coefficient, the fourth cosine similarity distribution value and the fourth coefficient, and the fifth cosine similarity distribution value and the fifth coefficient are obtained respectively. The sum of each product is then obtained to obtain a first intermediate result. The first coefficient represents the number of parameters included in the first parameter matrix, the second coefficient represents the number of parameters included in the second parameter matrix, the third coefficient represents the number of parameters included in the third parameter matrix, the fourth coefficient represents the number of parameters included in the fourth parameter matrix, and the fifth coefficient represents the number of parameters included in the fifth parameter matrix. The first coefficient, the second coefficient, the third coefficient, the fourth coefficient, and the fifth coefficient are summed to obtain a second intermediate result; The ratio of the first intermediate result to the second intermediate result is defined as Sij.

9. The method according to claim 6, wherein, The process of fusing the target layers into a single fusion layer includes: For different types of parameter matrices, the following processing is performed: the mean value of the parameter matrix of the aforementioned type in each target layer is obtained; The obtained mean values ​​are used as the parameter matrix in the fusion layer to obtain the fusion layer.

10. A text processing device based on a large model, comprising: Acquisition module and processing module; The acquisition module is used to acquire the word sequence corresponding to the input text; The processing module is configured to perform the following processing on each word in the word sequence: in response to determining that the word needs to be processed by the fusion layer in the target large model, determine that the word corresponds to the original input of the fusion layer, use the fusion layer to perform inference calculation on the original input, and perform the following predetermined processing: use the fusion layer to perform inference calculation on the most recently obtained calculation result, determine the most recently obtained calculation result as a candidate result, and determine the most recently obtained calculation result before the candidate result as a reference result; In response to determining that the termination condition is met based on the candidate result and the reference result, the candidate result is determined as the target processing result; in response to determining that the termination condition is not met, the predetermined processing is repeated. The target large model is obtained by fusing Lm consecutively adjacent target layers in the large model to be compressed into a fusion layer, where 1 < Lm < L, and L represents the number of layers in the large model to be compressed. The target layer is determined by identifying the elements located on the main diagonal of the similarity matrix as target elements. For each target element, in response to the ability to extract an Lm*Lm submatrix with the target element as the top left vertex from the similarity matrix, the norm value of the submatrix is ​​determined according to a predetermined norm algorithm, and the candidate layer corresponding to the submatrix with the maximum value is selected from the obtained norm values. Each layer in the large model to be compressed is used as a candidate layer. The similarity matrix is ​​L*L in size, where the element Sij located in the i-th row and j-th column is used to represent the parameter similarity between the i-th candidate layer and the j-th candidate layer, where 1 ≤ i ≤ L and 1 ≤ j ≤ L.

11. A large model compression device, comprising: The module includes a preprocessing module, a filtering module, and a compression module; The preprocessing module is used to obtain the large model to be compressed and determine each layer in it as a candidate layer. The filtering module is used to filter Lm sequentially adjacent target layers from each candidate layer according to predetermined filtering conditions, including: generating an L*L similarity matrix, where the element Sij in the i-th row and j-th column represents the parameter similarity between the i-th candidate layer and the j-th candidate layer, 1≤i≤L, 1≤j≤L, 1<Lm<L, and L represents the number of candidate layers included in the large model to be compressed; determining the elements on the main diagonal of the similarity matrix as target elements; for each target element, in response to the ability to extract an Lm*Lm submatrix with the target element as the top left vertex from the similarity matrix, determining the norm value of the submatrix according to a predetermined norm algorithm; selecting the maximum value from the obtained norm values, and determining the candidate layer corresponding to the submatrix corresponding to the maximum value as the target layer; The compression module is used to fuse each target layer into a fusion layer to obtain a target large model as the compression result. For each word in the word sequence corresponding to the input text, it performs the following processing: In response to determining that the word needs to be processed using the fusion layer in the target large model, it determines the original input of the fusion layer corresponding to the word, uses the fusion layer to perform inference calculations on the original input, and executes the following predetermined processing: using the fusion layer to perform inference calculations on the most recently obtained calculation result, and determines the most recently obtained calculation result as a candidate result, and determines the most recently obtained calculation result before the candidate result as a reference result; in response to determining that the termination condition is met based on the candidate result and the reference result, it determines the candidate result as the target processing result; in response to determining that the termination condition is not met, it repeats the predetermined processing.

12. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.

13. 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-9.

14. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the method of any one of claims 1-9.