A method, device and storage medium for optimizing deep learning models

By adjusting and sharing the matrix size of the deep learning model, combined with data filtering and quantification processing, the problem of insufficient storage and computing resources of the deep learning model on the client is solved, and efficient operation and offline processing capabilities on the client are achieved.

CN110633801BActive Publication Date: 2024-09-24BEIJING SAMSUNG TELECOM R&D CENT +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN201910133986.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-08-28
Filing Date
2019-02-22
Publication Date
2024-09-24
Estimated Expiration
2039-02-22

AI Technical Summary

Technical Problem

The existing deep learning model based on neural networks has a large number of parameters due to the deep structure, which makes the client, especially the mobile device, unbearable in terms of storage and computing resources, and requires frequent uploading of requests to the cloud server for processing, affecting privacy and network connectivity. dependency.

Method used

By adjusting the matrix size in the deep learning model to make it consistent in size, sharing weights in specific dimensions, and combining data filtering, parameter quantification, and sparse storage, the storage and computing efficiency of the model is optimized.

Benefits of technology

Significantly reduces the size and computing resource requirements of deep learning models, enabling them to run effectively on the client, breaking network connection limitations, achieving offline processing capabilities, and improving the model's processing efficiency and storage density.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110633801B_ABST
    Figure CN110633801B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention proposes an optimization processing method for a deep learning model, including: adjusting the size of at least two matrices in the matrix of the deep learning model so that at least two matrices have the same size; and making at least two matrices share weights. The method can significantly reduce the size of the model, which is conducive to processing using the generated deep learning model on the client. At the same time, the embodiment of the present invention also provides a corresponding optimization processing device, data processing method, equipment and storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning, and in particular to an optimization processing method, an optimization processing device, a data processing method, a device and a storage medium for a deep learning model. Background Art

[0002] Deep learning models are the core content of modern artificial intelligence technology. Taking the well-known machine translation technology as an example, the machine translation model is a deep learning model that can automatically translate one language into another. Compared with manual translation, machine translation has the advantages of high translation efficiency, low learning and translation costs, and easy expansion to different languages. Therefore, with the vigorous development of international economic trade, international tourism and other industries, the role of machine translation technology in international communication is becoming increasingly important. Some multinational companies with international influence, such as Google, Microsoft, Baidu and other companies, are researching machine translation technology and have released multilingual translation systems, which greatly improves the convenience of users in international communication.

[0003] According to different machine translation algorithm frameworks, current machine translation technology can be roughly divided into the following three methods: 1) Rule-based machine translation, in which linguists write translation rules, handle rule conflicts, and maintain rule bases. When a sentence is input, a translation is generated according to the translation rules; 2) Statistical machine translation, based on the parallel corpus, automatically learns the word alignment between parallel sentence pairs, automatically extracts translation rules and estimates translation probabilities, establishes a translation model and performs parameter tuning; when a sentence is input, N translation candidates are generated according to the translation rules, and the candidates are scored and ranked according to the translation model and language model, and the translation candidate ranked first is used as the final translation; 3) Neural network machine translation, based on the training method of parallel corpus and recurrent neural network, the network parameters are automatically learned; when a sentence is input, a translation is automatically generated according to the network structure.

[0004] The main problem with existing deep learning models based on neural networks is that since most deep learning models based on neural networks are deep neural network models, the models contain a large number of parameters, which requires a lot of resources for both storage and calculation.

[0005] At present, the solutions for neural network deep learning models of most clients (such as clients using mobile devices) are based on uploading processing requests to cloud servers, which are then processed and returned to the client. On the one hand, this causes the client user information to be transmitted to the cloud server, which is undoubtedly very unfriendly to users who value privacy. On the other hand, when the client cannot connect to the network, the application that performs the processing will not work. On the server side, the resources for storing the model can be ignored, and computing resources can be used to increase processing speed through distributed scheduling. However, on the client side, especially on the client side using mobile devices, both storage resources and computing resources are particularly valuable. When the neural network deep learning model is implanted in a mobile device, the mobile device cannot withstand the huge resource consumption of the model.

[0006] Therefore, there is a need for a solution that can be applied to the client and optimize the generation process of the deep learning model to at least partially solve the above problems. Summary of the invention

[0007] In order to solve at least some of the above problems, an embodiment of the present invention proposes a method and device for generating a deep learning model.

[0008] According to a first aspect of the present invention, there is provided a method for optimizing a deep learning model, comprising: adjusting the sizes of at least two matrices in the matrix of the deep learning model so that the at least two matrices have the same size; and enabling the at least two matrices to share weights.

[0009] In some embodiments, the at least two matrices include at least two of the following matrices: a word vector matrix of the encoding end of the deep learning model, a word vector matrix of the decoding end of the deep learning model, a parameter matrix of the output fully connected layer of the deep learning model, a word vector matrix of the encoding end after the deep learning model converts input and output, a word vector matrix of the decoding end after the deep learning model converts input and output, and a parameter matrix of the output fully connected layer after the deep learning model converts input and output.

[0010] In some embodiments, the at least two matrices include a first matrix and a second matrix, and adjusting the size of at least two matrices in the matrix of the deep learning model includes: deleting word vectors from the first matrix; and / or padding word vectors into the second matrix.

[0011] In some embodiments, deleting word vectors from the first matrix includes: sorting the word lists corresponding to the first matrix and the second matrix according to word frequency, wherein the size of the first matrix is ​​larger than the size of the second matrix; deleting words in the word list corresponding to the first matrix after sorting according to word frequency, so that the size of the first matrix after deletion is the same as the size of the second matrix; filling word vectors into the second matrix includes: sorting the word lists corresponding to the first matrix and the second matrix according to word frequency, wherein the size of the first matrix is ​​larger than the size of the second matrix; filling identifiers into the word list corresponding to the second matrix according to word frequency, so that the size of the second matrix after filling is the same as the size of the first matrix.

[0012] In some embodiments, enabling the at least two matrices to share weights includes: determining a shared characteristic dimension of the at least two matrices according to a set sharing ratio; and enabling the at least two matrices to share weights at the shared characteristic dimension.

[0013] In some embodiments, the sharing rate is a real number greater than 0 and less than or equal to 1.

[0014] In some embodiments, the at least two matrices are weight-shared, including: according to a set first sharing rate 1, the at least two matrices are weight-shared at all feature dimensions to obtain a first weight-sharing matrix; according to a set second sharing rate, the first weight-sharing matrix and at least one other matrix are weight-shared at the shared feature dimensions determined by the second sharing rate; wherein the at least one other matrix includes other matrices in the deep learning model except the at least two matrices used to obtain the first weight-sharing matrix and / or other weight-sharing matrices obtained by weight sharing.

[0015] In some embodiments, the at least two matrices are weight-shared, including: according to a set first sharing rate 1, at least two matrices among the word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, and the transpose of the parameter matrix of the output fully connected layer of the deep learning model are made equal to obtain a second weight sharing matrix; according to the set first sharing rate 1, at least two matrices among the word vector matrix of the encoding end after the deep learning model input and output conversion, the word vector matrix of the decoding end after the deep learning model input and output conversion, and the transpose of the parameter matrix of the output fully connected layer after the deep learning model input and output conversion are made equal to obtain a third weight sharing matrix; according to a set second sharing rate, the second weight sharing matrix and the third weight sharing matrix are made equal at the shared feature dimension determined by the second sharing rate.

[0016] In some embodiments, the at least two matrices are weight-shared, including: according to a set first sharing rate 1, the word vector matrix at the decoding end of the deep learning model is made equal to the transpose of the parameter matrix of the output fully connected layer of the deep learning model to obtain a second weight sharing matrix; according to the set first sharing rate 1, the word vector matrix at the decoding end after the deep learning model input and output are converted is made equal to the transpose of the parameter matrix of the output fully connected layer after the deep learning model input and output are converted to obtain a third weight sharing matrix; according to the set first sharing rate 1, the word vector matrix at the encoding end of the deep learning model is made equal to the third weight sharing matrix to obtain a fourth weight sharing matrix; according to the set first sharing rate 1, the word vector matrix at the encoding end after the deep learning model input and output are converted is made equal to the second weight sharing matrix to obtain a fifth weight sharing matrix; according to the set second sharing rate, the fourth weight sharing matrix is ​​made equal to the fifth weight sharing matrix at the shared feature dimension determined by the second sharing rate.

[0017] In some embodiments, during the generation process of the deep learning model, at least one of the following methods is also used for optimization: filtering the data set output by the pre-trained model, adding the filtered data set to the training set as the training set of the deep learning model; making the word vectors of similar words in the word vector table of the deep learning model share row vectors and / or column vectors; making different network layers with the same structure in the deep learning model share the same parameters; setting the weights approaching zero in the model parameters of the deep learning model to zero; storing the model parameters in a sparse matrix storage method; and quantizing the model parameters of the deep learning model to a set type.

[0018] According to a second aspect of the present invention, there is provided an optimization processing device for a deep learning model, comprising: an adjustment module, configured to adjust the sizes of at least two matrices in the matrix of the deep learning model so that the at least two matrices have the same size; and a sharing module, configured to enable the at least two matrices to share weights.

[0019] According to a third aspect of the present invention, a method for data processing is provided, comprising: using a deep learning model to process data input by a user; wherein at least two matrices of the deep learning model have the same size and share weights.

[0020] According to a fourth aspect of the present invention, there is provided an electronic device, comprising: a processor; and a memory configured to store machine-readable instructions, which, when executed by the processor, causes the processor to perform any of the above methods.

[0021] According to a fifth aspect of the present invention, there is provided a computer-readable storage medium having executable instructions stored thereon, wherein when the instructions are executed by a processor, the processor is caused to perform any of the above methods.

[0022] According to the technical solution of an embodiment of the present invention, by adjusting the sizes of at least two matrices of the deep learning model to make them of the same size and sharing the weights of at least two matrices, the size of the model is significantly reduced, which is conducive to processing using the generated deep learning model on the client, breaking the network limitations, and enabling users to obtain processing results without having to upload information to the server. At the same time, users can use mobile devices to process data in real time based on optimized deep learning models even if they are not connected to the network. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The above and other features of the present invention will become more apparent from the following detailed description taken in conjunction with the accompanying drawings, in which:

[0024] Figure 1 A flowchart of an optimization processing method for a deep learning model according to an embodiment of the present invention is shown;

[0025] Figure 2 A schematic diagram showing an example strategy for adjusting the size of a word vector matrix at an encoding end and a word vector matrix at a decoding end according to an embodiment of the present invention is shown;

[0026] Figure 3 A schematic diagram of a sharing strategy for matrix sharing in a deep learning model according to an embodiment of the present invention is shown;

[0027] Figure 4 A schematic diagram showing an operation mode of matrix sharing in a deep learning model according to an embodiment of the present invention is shown;

[0028] Figure 5 A diagram showing an implementation example of a sharing strategy for bidirectional matrix sharing in a bidirectional translation model according to an embodiment of the present invention;

[0029] Figures 6 to 10 Schematic diagrams showing specific implementations of generating a deep learning model (machine translation model) using different optimization processing methods according to an embodiment of the present invention are shown respectively;

[0030] Fig.11 A schematic block diagram of an optimization processing device for a deep learning model according to an embodiment of the present invention is shown;

[0031] Fig.12 An overall framework diagram for generating a deep learning model according to an embodiment of the present invention is shown;

[0032] Fig.13A flowchart for generating training for a deep learning model according to an embodiment of the present invention is shown;

[0033] Fig.14 A block diagram of a device according to an embodiment of the present invention is schematically shown.

[0034] In the drawings, the same or similar structures are marked with the same or similar reference numerals. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings. It should be noted that the following description is only for illustration and is not intended to limit the present disclosure. In the following description, in order to provide a thorough understanding of the present disclosure, a large number of specific details are set forth. However, it is obvious to a person of ordinary skill in the art that these specific details do not have to be adopted to implement the present disclosure. In other examples, in order to avoid confusing the present disclosure, known circuits, materials or methods are not specifically described.

[0036] Throughout the specification, references to "one embodiment," "an embodiment," "an example," or "an example" mean that a particular feature, structure, or characteristic described in conjunction with the embodiment or example is included in at least one embodiment of the present disclosure. Therefore, the phrases "in one embodiment," "in an embodiment," "an example," or "an example" appearing in various places throughout the specification do not necessarily all refer to the same embodiment or example. In addition, particular features, structures, or characteristics may be combined in one or more embodiments or examples in any suitable combination and / or sub-combination. In addition, it will be appreciated by those of ordinary skill in the art that the figures provided herein are for illustrative purposes and that the figures are not necessarily drawn to scale. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0037] In order to facilitate the understanding of the technical solution of the present invention, the method for generating a deep learning model of the embodiment of the present invention is described below by taking the well-known machine translation model as an example. It should be understood that the following description of the machine translation model is applicable to all deep learning models.

[0038] Figure 1 FIG. 1 is a flow chart showing a method for optimizing a deep learning model according to an embodiment of the present invention. Figure 1 As shown, the optimization processing method includes:

[0039] Step S110, adjusting the sizes of at least two matrices in the matrix of the deep learning model so that the sizes of at least two matrices are the same.

[0040] Step S120: enabling at least two matrices to share weights.

[0041] In order to meet the processing capabilities of the client and enable the generated deep learning model to run better on the client, in an embodiment of the present invention, in the process of generating the deep learning model, an optimization processing method for sharing weights of at least two matrices in the deep learning model is adopted.

[0042] In some embodiments, the at least two matrices involved in weight sharing include but are not limited to at least two of the following matrices: a word vector matrix at the encoding end of the deep learning model, a word vector matrix at the decoding end of the deep learning model, a parameter matrix of the output fully connected layer of the deep learning model, a word vector matrix at the encoding end after the deep learning model converts input and output, a word vector matrix at the decoding end after the deep learning model converts input and output, and a parameter matrix of the output fully connected layer after the deep learning model converts input and output.

[0043] The optimization method of the embodiment of the present invention will be described below by taking the machine translation model in the deep learning model as an example, but the embodiment of the present invention is not limited to this and can also be applied to other deep learning models.

[0044] When weights are shared for at least two matrices, if the sizes of at least two matrices are different, for example, at least two matrices include a first matrix and a second matrix, and the size of the first matrix is ​​larger than the size of the second matrix, direct sharing will result in a mismatch in the shapes of the matrices. Taking the machine translation model as an example, if the sizes of the two word vector matrices are different, for example, when the word vector matrix at the encoding end is made equal to the word vector matrix at the decoding end, if the size of the vocabulary corresponding to the word vector matrix at the encoding end is different from the size of the vocabulary corresponding to the word vector matrix at the decoding end, direct sharing will result in a mismatch in the shapes of the word vector matrices. Therefore, in an embodiment of the present invention, the matching between the word vector matrices can be achieved by adjusting the size of at least two word vector matrices to share weights, thereby achieving weight sharing between at least two word vector matrices.

[0045] In some embodiments, word vectors that meet set requirements can be deleted from the first word vector matrix (first matrix) until the first word vector matrix (first matrix) and the second word vector matrix (second matrix) are the same size.

[0046] In some embodiments, the second word vector matrix (second matrix) can be filled with word vectors that meet the set requirements until the first word vector matrix (first matrix) and the second word vector matrix (second matrix) are the same size.

[0047] In the following description, no distinction is made between the first word vector matrix and the first matrix, and between the second word vector matrix and the second matrix.

[0048] In some embodiments, word vectors that meet the set requirements can be deleted from the first word vector matrix, and word vectors that meet the set requirements can be added to the second word vector matrix at the same time until the first word vector matrix and the second word vector matrix are the same size.

[0049] It should be noted that when the size of the word vector matrix is ​​adjusted, it is necessary to adjust the word list after sorting. It should be noted that the sorting mentioned in the embodiment of the present invention is not the sorting of the word vectors, but the sorting of the word list.

[0050] For example, take the word vector matrix of the deep learning model encoding end and the word vector matrix of the deep learning model decoding end as an example. Assume that the training set data of the encoding end is C s {s 1 ,s 2 , ..., s n}, the vocabulary extracted from the encoding end training set data is The training set data of the decoding end is C t {t 1 , t 2 , ..., t n}, the vocabulary extracted from the training set data at the decoding end is That is, respectively and Sort.

[0051] Furthermore, in the embodiment of the present invention, padding refers to padding the vocabulary. For example, a vocabulary of size 30,000 is filled with 10,000 of the same special identifier to make it the same size as a vocabulary of size 40,000, and then the word vectors of words in the same position are shared. Figure 2 , we will still take the word vector matrix at the encoding end and the word vector matrix at the decoding end of the deep learning model as an example to illustrate.

[0052] like Figure 2 As shown, it is shown that the word vector matrix of the encoding end (equivalent to the first word vector matrix) is larger than the word vector matrix of the decoding end (equivalent to the second word vector matrix). In order to adjust the size of the two, a deletion strategy can be adopted, that is, the word vector matrix is ​​uniformly constructed according to the word vector matrix of the decoding end. In some embodiments, the process specifically includes first sorting the word tables of the encoding end and the decoding end respectively by word frequency. That is, the word tables corresponding to the first word vector matrix and the second word vector matrix are sorted according to word frequency. Among them, the words in the word table corresponding to the first word vector matrix are obtained from the first training set data, and the words in the word table corresponding to the second word vector matrix are obtained from the second training set data. The word frequency of the words in the word table corresponding to the first word vector matrix is ​​obtained by statistics of the first training set data, and the word frequency of the words in the word table corresponding to the second word vector matrix is ​​obtained by statistics of the second training set data.

[0053] like Figure 2 As shown in FIG. 1 , a horizontal line arranged parallel to a word indicates the frequency of a word. The longer the horizontal line, the greater the frequency of the word. The word lists at the encoding end and the decoding end in the figure are sorted from large to small according to the frequency of the word.

[0054] Next, the words in the sorted vocabulary corresponding to the first word vector matrix are deleted according to word frequency until the larger vocabulary is the same length as the smaller vocabulary, even if the size of the first word vector matrix is ​​the same as the size of the second word vector matrix. In some embodiments, the words with lower word frequency in the sorted larger vocabulary can be deleted. Figure 2 As shown in the non-shared area in the figure, the last three words in the vocabulary can be deleted. In the embodiment of the invention, these are the words with lower frequency in the vocabulary.

[0055] In some embodiments, the word vector matrix can be uniformly constructed according to the larger word list, that is, a padding strategy is adopted to adjust the size of the two. Specifically, the word lists at the encoding end and the decoding end are first sorted by word frequency. That is, the word lists corresponding to the first word vector matrix and the second word vector matrix are sorted according to word frequency, such as Figure 2 The arrangement process is the same as the above embodiment and will not be described in detail here.

[0056] Next, the identifiers are filled into the word list corresponding to the second word vector matrix according to the word frequency, until the smaller word list is the same length as the larger word list, even if the size of the first word vector matrix after filling is the same as the size of the second word vector matrix. In some embodiments, some filler words can be filled into the smaller word list at positions with lower word frequency. Figure 2 As shown, in this case, Figure 2 The non-shared area in the decoder also becomes a shared area. The identifier can be filled at the end of the decoder vocabulary. For example, three words (not shown in the figure) are added after the word "slu" in the decoder vocabulary, which correspond to the last three words in the encoder vocabulary respectively.

[0057] In some embodiments, the filler words that fill in the smaller vocabulary can be the same special identifier, that is, Figure 2 The same special identifier is filled in the position where the word frequency of the decoding end is the smallest (for example, the last three). Here, the special identifier can be an identifier without actual meaning. These identifiers without actual meaning have no relationship with the words in the word list of the encoding end and the decoding end, and will not be actually used.

[0058] In some embodiments, two adjustment strategies may be implemented for the vocabulary corresponding to at least two word vector matrices. For example, assuming that the size of the vocabulary corresponding to the larger word vector matrix is ​​3500 and the size of the vocabulary corresponding to the smaller word vector matrix is ​​3300, a deletion strategy may be implemented for both vocabulary at the same time, that is, the size of the vocabulary corresponding to the larger word vector matrix and the size of the vocabulary corresponding to the smaller word vector matrix may be deleted to 3000, so that the larger word vector matrix has the same size as the smaller word vector matrix.

[0059] For another example, assuming that the size of the vocabulary corresponding to the larger word vector matrix is ​​3500, and the size of the vocabulary corresponding to the smaller word vector matrix is ​​2800, a deletion strategy can be implemented for the larger vocabulary, while a padding strategy can be implemented for the smaller vocabulary. That is, the size of the vocabulary corresponding to the larger word vector matrix can be deleted to 3000, while the size of the vocabulary corresponding to the smaller word vector matrix can be padded to 3000, so that the larger word vector matrix has the same size as the smaller word vector matrix.

[0060] Since the training set data at the encoding end (such as C s ) and the decoder training set data (e.g. C t ) have a one-to-one correspondence, so it can be considered that the vocabulary W extracted from their training set data is s With W t The word frequency distribution of also has a corresponding relationship at the semantic level. Therefore, in the embodiment of the present invention, a method for weight sharing based on the sorting of the word vector table is proposed.

[0061] According to the foregoing specific embodiment, adjusting the size of at least two matrices includes:

[0062] 1) According to the word frequency, s and W t Sorting, assuming that the sorted vocabulary is W s ′ and W t ′;

[0063] 2) Share word vectors for words in the same order.

[0064] Specifically, if the vocabulary size of one party exceeds the vocabulary size of the other party, the word vectors of the excess part will not be shared. At this time, the excess party can be deleted (deletion strategy) or the other party can be filled (filling strategy).

[0065] In some embodiments, enabling at least two matrices to share weights includes: determining a shared characteristic dimension of the at least two matrices according to a set sharing ratio, and enabling the at least two matrices to share weights at the shared characteristic dimension.

[0066] In some embodiments, the set sharing rate is a real number greater than 0 and less than or equal to 1, and determining the shared characteristic dimensions of at least two matrices may include: determining the characteristic dimensions for weight sharing from the characteristic dimensions of the matrices according to the set sharing rate.

[0067] Figure 3 A schematic diagram of a sharing strategy for matrix sharing in a deep learning model according to an embodiment of the present invention is shown below. Figure 3 An example showing how to share matrices in a deep learning model.

[0068] like Figure 3 As shown, it is assumed that the two matrices to be shared are matrix a and matrix b, and their feature dimensions are both D. Figure 3 In , the feature dimension is represented by the columns of the matrix along the vertical direction. Assuming that the sharing rate is set to r, and r is a real number greater than 0 and less than or equal to 1, the feature dimension size of the shared part between matrix a and matrix b is D*r, and the feature dimension size of the exclusive part between matrix a and matrix b is D*(1-r).

[0069] It is easy to understand that the smaller the value of the sharing rate r, the fewer the shared feature dimensions, the larger the obtained parameter matrix, and the better the performance of the final deep learning model. The larger the value of the sharing rate r, the more shared feature dimensions, the smaller the obtained parameter matrix, and the more streamlined the final deep learning model, but some performance may be lost. Therefore, the value of the sharing rate r can be determined according to the specific design needs of the model.

[0070] Further, according to an embodiment of the present invention, if the sharing rate r is equal to 1, the matrix a and the matrix b can be shared in all feature dimensions. At this time, the matrix a and the matrix b can be represented by a combined weight sharing matrix.

[0071] In some embodiments, the obtained weight sharing matrix and at least one other matrix may be further weight-shared at the shared feature dimension determined by the reset sharing ratio, and the at least one other weight sharing matrix may include other matrices in the deep learning model other than the at least two matrices used to obtain the weight sharing matrix and / or other weight sharing matrices obtained by weight sharing. Figure 4 Provide explanation.

[0072] Figure 4 FIG. 1 is a schematic diagram showing a matrix sharing method in a deep learning model according to an embodiment of the present invention. Figure 4As shown in the figure, assuming that the number of matrices in the deep learning model is n, in order to distinguish different matrices, different matrices are assigned consecutive different numbers 1, 2, ..., n. For the convenience of description, the matrix numbered i is called matrix i. When matrix i and matrix j share weights, the matrices after weight sharing can be combined into one matrix, which is represented as matrix ij. If there is still a sharing operation, matrix ij will replace matrix i and matrix j and share with other matrices at the set sharing rate. Figure 4 In the example, it is assumed that the set sharing rate for each sharing operation is 1. After one sharing operation, the number of matrices in the deep model becomes n-1. After multiple sharing operations, the number of matrices in the deep model becomes n-4. For details, see Figure 4 For example, matrix 1 is shared with matrix 2 to obtain matrix 12, matrix 3 is shared with matrix 4 to obtain matrix 34; matrix 12 is shared with matrix 34 to obtain matrix 1234; matrix 1234 is shared with matrix n to obtain matrix 1234n. If the parameter size of the matrix is ​​M, the parameter size of the original deep model is M*n+Others, where Others is the sum of the parameters of other matrices that do not participate in the sharing operation. After the above rounds of sharing operations, the parameter size of the entire deep model becomes M*(n-4)+Others, and the parameter size is reduced by 4*M. The larger M is, the greater the compression of the storage space of the deep model.

[0073] Based on the above matrix sharing method, matrix sharing can be achieved through multiple nested operations.

[0074] In some embodiments, according to a sharing rate of 1, at least two matrices among the word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, and the transpose of the parameter matrix of the output fully connected layer of the deep learning model are made equal to obtain a first weight sharing matrix; according to a sharing rate of 1, at least two matrices among the word vector matrix of the encoding end after the deep learning model input and output conversion, the word vector matrix of the decoding end after the deep learning model input and output conversion, and the transpose of the parameter matrix of the output fully connected layer after the deep learning model input and output conversion are made equal to obtain a second weight sharing matrix; according to a set sharing rate, the first weight sharing matrix and the second weight sharing matrix are made equal at the shared feature dimension determined by the set sharing rate.

[0075] In some embodiments, according to a sharing rate of 1, the word vector matrix at the decoding end of the deep learning model is equal to the transpose of the parameter matrix of the output fully connected layer of the deep learning model to obtain a first weight sharing matrix; according to a sharing rate of 1, the word vector matrix at the decoding end after the deep learning model converts the input and output is equal to the transpose of the parameter matrix of the output fully connected layer after the deep learning model converts the input and output to obtain a second weight sharing matrix; according to a sharing rate of 1, the word vector matrix at the encoding end of the deep learning model is equal to the second weight sharing matrix to obtain a third weight sharing matrix; according to a sharing rate of 1, the word vector matrix at the encoding end after the deep learning model converts the input and output is equal to the first weight sharing matrix to obtain a fourth weight sharing matrix; according to a set sharing rate, the third weight sharing matrix and the fourth weight sharing matrix are equal at the shared feature dimension determined by the set sharing rate.

[0076] Combine the following Figure 5 , taking the bidirectional translation model as an example, the implementation of the above sharing strategy is explained in detail.

[0077] Figure 5 An example of implementing a sharing strategy for bidirectional matrix sharing in a bidirectional translation model according to an embodiment of the present invention is shown. Figure 5 As shown, model A->B represents the translation from language A to language B, and model B->A represents the translation from language B to language A.

[0078] Assume that the size of the word vector matrix has been adjusted according to the above-mentioned embodiment. For the convenience of expression, in model A->B, the word vector matrix that has been resized at the encoding end is recorded as A1, the word vector matrix that has been resized at the decoding end is recorded as B1, and the output fully connected layer matrix is ​​recorded as L1; in model B->A, the word vector matrix that has been resized at the encoding end is recorded as B2, the word vector matrix that has been resized at the decoding end is recorded as A2, and the output fully connected layer matrix is ​​recorded as L2. Define the sharing function: S(i, j, k, ..., p), where p is the sharing rate, p is a real number belonging to (0, 1], and i, j, k, ... are all matrices that need to be shared. S(i, j, k, ..., p) means that matrices i, j, k, ... are shared at a sharing rate of p.

[0079] First, let’s focus on the matrix sharing strategy in the unidirectional model. We can see that the same matrix is ​​used in the encoding, decoding, and output fully connected layers of a single model. That is, there is a matrix sharing with a sharing rate of 1 between the encoding, decoding, and output fully connected layers of the model, which is denoted as S(A1, B1, L1, 1) in model A->B and S(A2, B2, L2, 1) in model B->A.

[0080] Then, the dotted box represents the sharing of word vector matrices between bidirectional models. It can be seen that the word vector matrix sharing between models is partial sharing. Assuming the sharing rate is p1, the final sharing strategy can be recorded as S(S(A1, B1, L1, 1), S(A2, B2, L2, 1), p1). That is, on the basis of sharing within each unidirectional model, sharing is carried out between bidirectional models. If the matrix size is (m, n), the parameter size of the bidirectional translation model before sharing is: m*n*6+Others, where Others is the model parameter size that is not shared. After sharing, the parameter size of the bidirectional translation model is reduced to: m*n*(2-p1)+Others. Since the word vector matrix of the bidirectional translation model accounts for a large proportion of the entire model, this optimization greatly compresses the storage space of the bidirectional translation model.

[0081] Optionally, when the bidirectional model is first shared between models and then shared within the unidirectional model, there is also a sharing strategy: S(S(S(B1, L1, 1), B2, 1), S(A1, S(A2, L2, 1), 1), p2).

[0082] The execution process of the above sharing strategy is: the first step is to share the decoding end word vector matrix and the output fully connected layer matrix of each of the two models at a sharing rate of 1; the second step is to share the two matrices obtained by sharing with the encoding end word vector matrix of the parallel model at a sharing rate of 1; the third step is to share the two matrices obtained after sharing in the second step at a sharing rate of p2. At this point, the parameter size of the bidirectional translation model is reduced to: m*n*(2-p2)+Others, where Others is the model parameter size that is not shared.

[0083] In an embodiment of the present invention, at the network design level, a weight sharing method is proposed to achieve the purpose of reducing the number of parameters, solve the problem of excessive physical storage volume of parameters of the encoding end, decoding end and decoding end output layer, and significantly reduce the storage volume of the model.

[0084] The above operation is only a specific example provided to illustrate the technical solution of the embodiment of the present invention and should not be regarded as limiting the protection scope of the present invention.

[0085] In addition, after the deep learning model is generated, the generated deep learning model can also be sent to the client or sent to the client based on the client's request, so that the deep learning model can be used to perform processing on the client.

[0086] In this embodiment, a deep learning model is generated at an entity other than the client, the client receives the generated deep learning model from the other external entity and performs processing at the client using the deep learning model.

[0087] It is easy for those skilled in the art to understand that after the generated deep learning model is stored on the client, processing can be performed using the deep learning model stored on the client without a network connection, breaking the network limitations and enabling users to obtain processing results without having to upload information to the server. At the same time, users can use mobile devices to perform real-time deep learning model-based processing without being connected to the network.

[0088] In some embodiments, other entities (or some entities) used to generate deep learning models generally have powerful storage and computing capabilities. Using other entities other than the client to process the process of generating deep learning models is conducive to optimizing the model generation process and thereby improving the quality of the generated model.

[0089] In some embodiments, the process of generating a deep learning model also includes filtering the training data set used to generate the deep learning model.

[0090] In some embodiments, the processing method specifically includes: using a trained deep learning model to process a training data set to obtain a set of processing results; using the standard processing results of the training data set as a reference to filter the set of processing results; and using the training data set corresponding to the filtered set of processing results as the training data set used to generate the deep learning model.

[0091] Figure 6 A schematic flow chart showing a specific implementation of the above optimization processing method using a machine translation model as an example is shown.

[0092] like Figure 6 As shown, first, the training data set is translated using a trained machine translation model to obtain a translation set. In some embodiments, the trained machine translation model may include an existing machine translation model (transformer) set on the server side. Such machine translation models are generally pre-trained heavyweight models with more parameters. Moreover, since such machine translation models have been fully trained, the values ​​of their model parameters are more reasonable and generally have better translation quality.

[0093] like Figure 6 As shown, the source language data constituting the training set data is taken as input and input into the pre-trained heavyweight model, and the pre-trained heavyweight model is used to translate the input source language data, and the obtained translation result is called a translation set.

[0094] Then, the obtained translation set is filtered using the standard translation results of the training data set as a reference. Figure 6As shown in FIG, by comparing the translation set with the standard translation results of the training data set, a batch of better corpora are selected from the translation set. This process is called filtering. The quality of the translation set can be improved by filtering the translation set.

[0095] Finally, the training data set corresponding to the filtered translation set is used as the training data set used to train the translation model. Figure 6 As shown, the filtered translation set and the training data set corresponding to the filtered translation set are simultaneously loaded onto an untrained lightweight translation model with fewer parameters, and the untrained lightweight translation model is trained. The model parameters that have been adjusted by the heavyweight model are used to guide the update of the parameters of the untrained lightweight translation model with fewer parameters, so as to guide the untrained lightweight translation model to make more correct optimization, which can improve the training quality of the model.

[0096] In this embodiment, a knowledge distillation method is proposed which utilizes a trained machine translation model to guide the training of an untrained lightweight translation model with fewer parameters. This method can improve the training effect of the model and overcome the problem of reduced model translation quality due to the reduction of model parameters of the untrained lightweight translation model.

[0097] The above operation is only a specific example provided to illustrate the technical solution of the embodiment of the present invention and should not be regarded as limiting the protection scope of the present invention.

[0098] In some embodiments, the process of generating a deep learning model also includes representing the word vector input to the deep learning model as a two-component shared embedding. Figure 7 A schematic flow chart showing the specific implementation of the above optimization processing method using a machine translation model as an example is shown below. Figure 7 The machine translation model shown is used as an example for explanation.

[0099] like Figure 7 As shown, in operation S710, the word vector table is initialized.

[0100] In some embodiments, the vocabulary is first filled into a two-dimensional table. In the two-dimensional table, words in the same row correspond to the same row vector, and words in the same column correspond to the same column vector, and then a word is represented by the corresponding row vector and column vector. This ensures that the representation of each word is unique, and words in the same row share the same row vector, and words in the same column share the same column vector.

[0101] In some embodiments, when initializing the word vector table, words may be randomly filled into the word vector table, and the vectors in the word vector table may be randomly initialized. In the embodiments of the present invention, the method for initializing the word vector table is not limited.

[0102] Next, in operation S720, the word vector table is fixed, the model is trained, and the row vectors and column vectors of the word vector table are updated according to the training results until the training is terminated after the model converges.

[0103] In some embodiments, the model is trained using sentence-based training corpus, and the row vectors and column vectors in the word vector table are updated based on the training results.

[0104] Next, in operation S730, the row vectors and column vectors of the word vector table are fixed, and the positions of the words are reallocated using the minimum weight best matching method.

[0105] In some embodiments, reallocation means that the row vectors and column vectors are fixed, and only the words are moved. For example, if a word starts at position (a1, b1), after reallocation, the word may move to position (a2, b2). The position of all words in the word vector table is adjusted using the method of minimum weight best matching.

[0106] Next, in operation S740, it is determined whether the model has converged, and if the model has converged, the training process is terminated. If the model has not converged, operations S720 and S730 are repeatedly performed to iteratively train the model until the model converges.

[0107] For example, after completing the reallocation of all words in the word vector table, the model is trained based on the reallocated word vector table, and the row vectors and column vectors in the word vector table are updated based on the training results. After the model is retrained until it converges, the positions of the words are reallocated using the minimum weight best matching method.

[0108] It is easy for a person skilled in the art to understand that, if the storage space of the original word vector table is assumed to be represented by N, the storage space occupied by the word vector table after the above training can be changed from the original N to 2*√N. In addition, by using the method of minimum weight best matching to find the connection between words, the positions of words are reallocated, thereby minimizing the training error, so that similar words can share the same row vector or column vector, and the word vector table is optimized.

[0109] It should be noted that this method is applicable to both the source language side and the target language side of the machine translation model.

[0110] In this embodiment, the word vector input to the machine translation model is represented as a two-component shared word vector, and the connection between words is found and the words are filled into the Founder vocabulary so that similar words share the same row vector or column vector. This can effectively solve the problem of excessive physical storage volume of the model.

[0111] The above operation is only a specific example provided to illustrate the technical solution of the embodiment of the present invention and should not be regarded as limiting the protection scope of the present invention.

[0112] In some embodiments, in the process of generating a deep learning model, the process also includes making network layers with the same structure share the same weight matrix, including specifically sharing all parameters of network layers with the same structure at the input end, and / or sharing all parameters of network layers with the same structure at the output end.

[0113] In some embodiments, making network layers with the same structure share the same weight matrix may also include sharing all parameters of consecutive network layers with the same structure at the input end, and / or sharing all parameters of consecutive network layers with the same structure at the output end. Figure 8 The schematic diagram of the above optimization method is shown in FIG. Figure 8 The schematic diagram shown is used as an example for explanation.

[0114] like Figure 8 As shown, there are cases where network layers with the same structure are connected in series in the model. In the network layer series structure, the network structure of each layer in the series structure is the same. The input data of the network layer series structure is used as the input data of the first network layer, and the input data of the second network layer is the output data of the first network layer. By analogy, the input data of the Nth network layer is the output data of the N-1th network layer. The output data of the Nth network layer is the output data of the network layer series structure. In the original model, the weight matrices of each layer of the network in this structure are independent of each other. In the embodiment, the weight matrix of each layer of the network is shared, which is equivalent to the same layer of network structure being looped N times, and the input of the i-th network structure is the output of the i-1th network structure.

[0115] In some embodiments, the process of generating a deep learning model also includes setting weights close to zero in the model parameters of the deep learning model to zero. Fig. 9 A schematic flow chart showing the specific implementation of the above optimization processing method using a machine translation model as an example is shown below. Fig. 9 The machine translation model shown is used as an example for explanation.

[0116] like Fig. 9 As shown, in operation S910, a trained model is obtained.

[0117] In some embodiments, the trained model may be a model obtained by training using the filtered training data set in the aforementioned embodiment, or a model obtained by training using the word vector represented as a two-component shared word vector in the aforementioned embodiment, or a model obtained by training by sharing the weights between the word vector matrix at the decoding end and the parameter matrix of the output layer at the decoding end, or any combination of the aforementioned trained models. Of course, the trained model may also be a model that has not undergone any of the above-mentioned processing, but has fully trained the model parameters to converge. Those skilled in the art may make a choice according to actual needs, and this is not limited in the present embodiment.

[0118] In addition, before training the model, the step of initializing the neural network is also included, which will not be repeated here.

[0119] Next, in operation S920, a deletion threshold of a node is set.

[0120] It is easy to understand that the deletion threshold can be set to a value close to zero.

[0121] Next, in operation S930, according to the set deletion threshold, the nodes in the model parameters whose weights are smaller than the deletion threshold are deleted.

[0122] In some embodiments, nodes with weights below a threshold are deleted and added to a weight update blacklist, and the weights of these nodes will no longer be updated in future training. To facilitate updates, the weight blacklist is generally written into the model in the form of a 0-1 matrix, which is called a mask layer. The shape of the mask layer is the same as the node weight. When the point of the mask layer at the same position is 0, it means that the node weight has been added to the update blacklist, and the node weight will be ignored in future updates.

[0123] Next, in operation S940, the model is trained, and the weights of the nodes that are not deleted are updated until the model converges.

[0124] After the model converges, jump out of the inner loop and continue to determine whether the training stop condition has been met, such as Fig. 9 As shown in operation S950 in .

[0125] If it is determined that the stopping condition is not met, operations S930 and S940 are repeated to iteratively train the model until the stopping condition is met.

[0126] In some embodiments, the stop condition may include a preset number of nodes to be deleted, so that when a sufficient number of nodes are not deleted, the model is iteratively trained. In other embodiments, the stop condition may include a preset number of iterations, and when the number of iterations does not reach the preset value, the model is iteratively trained. Those skilled in the art may also set the stop condition according to their knowledge and actual needs.

[0127] The model parameters processed as above include a large number of parameters with weights of 0, so the model parameters can be stored in a sparse matrix storage method.

[0128] In this embodiment, a pruning method is proposed for existing machine translation models that have a large number of parameters with weights close to zero. The weights of the model parameters that are close to zero are set to zero, the model is trained until the model converges, and then the parameters are iteratively filtered until the stopping condition is reached. The physical storage space of the model is reduced by storing it in a sparse matrix.

[0129] The above operation is only a specific example provided to illustrate the technical solution of the embodiment of the present invention and should not be regarded as limiting the protection scope of the present invention.

[0130] In some embodiments, the process of generating a deep learning model also includes quantizing model parameters of the deep learning model. Fig.10 A schematic flow chart showing the specific implementation of the above optimization processing method using a machine translation model as an example is shown below. Fig.10 The machine translation model shown is used as an example for explanation.

[0131] like Fig.10 As shown, first, obtain the trained model.

[0132] In some embodiments, the trained model may be a model obtained by training using the filtered training data set in the aforementioned embodiment, or a model obtained by training using the word vector represented as a two-component shared word vector in the aforementioned embodiment, or a model obtained by training after weight sharing between the word vector matrix of the decoding end and the parameter matrix of the output layer of the decoding end, or a model obtained by training after pruning the model parameters, or any combination of the aforementioned trained models. Of course, the trained model may also be a model that has not undergone any of the above-mentioned processing, but has fully trained the model parameters to converge. Those skilled in the art may make a choice according to actual needs, and this is not limited in the present embodiment.

[0133] In addition, before training the model, a step of initializing the neural network is also included. Those skilled in the art are familiar with these operations and will not be described in detail here.

[0134] Next, the model parameters are quantized.

[0135] In some embodiments, quantizing the model parameters may include reducing the storage space of the parameters in the model to a set type with smaller storage space. Further, in some embodiments, reducing the storage space of the parameters in the model may include reducing the number of bits of the parameters in the model. For example, converting a parameter with a storage type of float32 to a parameter with a storage type of float16.

[0136] Then, it is necessary to judge the quantization effect of the model. If a relatively ideal optimization effect has been achieved, the quantization can be considered completed. Otherwise, the model needs to be trained until the model converges.

[0137] In this embodiment, a method for quantizing parameters is proposed to address the shortcoming of existing machine translation models in that the amount of computation is too large when performing language processing calculations. The model parameters are quantized to a type that occupies less space, so as to achieve the purpose of reducing model storage space, reducing model operation memory, and improving model operation efficiency.

[0138] In some embodiments, when the type of a model parameter changes, the type of the programming statement corresponding to the parameter is modified according to the type of the changed parameter. For example, when a parameter of storage type float32 is converted to a parameter of storage type float16, the operation statement of the parameter of storage type float32 is correspondingly modified to an operation statement of the parameter of storage type float16.

[0139] The optimization methods shown in the above embodiments can be used alone or in combination with two or more processing methods. Table 1 shows the results of optimizing the existing machine translation model set on the server by comprehensively using the optimization processing methods given in the above embodiments.

[0140] Table 1. Translation model optimization results

[0141]

[0142]

[0143] As can be seen from Table 1, when the machine translation model is processed by layer sharing, weight sharing (deletion strategy) and quantization, the size of the model parameters can be reduced from 68M to 20M, and the size of the physical storage can be reduced from 272M to 21M, which significantly reduces the size of the model. For the bidirectional translation model, according to an embodiment of the present invention, after applying layer sharing, weight sharing (filling strategy) and quantization, the parameter size of the bidirectional model can be reduced from 136M to 32M, and the physical storage size can be reduced from 544M to 34M.

[0144] The method for generating a deep learning model provided in the embodiment of the present invention takes into account various aspects such as data, network structure, and storage optimization, and guarantees the quality of the model's language processing as much as possible on the basis of reducing the storage space of the deep learning model and accelerating the model's operating efficiency. Therefore, the volume of the deep learning model can be significantly reduced and the processing efficiency of the deep learning model can be improved with minimal loss of model processing quality.

[0145] In another embodiment of the present invention, a device for generating a deep learning model is also provided. Fig.11 A schematic block diagram of a device for generating a deep learning model according to an embodiment of the present invention is shown in FIG. Fig.11 As shown, the generating device of the deep learning model includes:

[0146] The determination module 1110 is configured to adjust the sizes of at least two matrices in the matrix of the deep learning model so that the at least two matrices have the same size.

[0147] The sharing module 1120 is connected to the determining module 1110 and is configured to enable at least two matrices to share weights.

[0148] In other embodiments of the present invention, a method for data processing is also provided, comprising using a deep learning model to process data input by a user; wherein at least two matrices of the deep learning model have the same size and share weights.

[0149] In some embodiments, the generated deep learning model may also be sent to the client. Accordingly, the client receives the deep learning model sent by the server from the server, and may perform processing using the deep learning model without a network connection.

[0150] In some embodiments, the client first actively sends a request to the server, and then receives the deep learning model sent by the server. For example, this request can be a request to download the deep learning model, or a request to allow the download of the deep learning model.

[0151] In some embodiments, after receiving the deep learning model, the client stores the model parameters of the deep learning model in a sparse storage manner.

[0152] In other embodiments, since the size of the model is reduced, the generated deep learning model can be made into an application app. The server first designs the app so that the client (such as a mobile phone, etc.) has sufficient capabilities to run the app. Then, when the user installs the app on the mobile phone, it no longer needs to be connected to the Internet for processing.

[0153] In addition, a processing method implemented on the client can be provided on the client (such as a mobile phone, etc.), the method including receiving a deep learning model sent by a server, and performing processing using the deep learning model.

[0154] Still taking machine translation as an example, the overall connection framework between the above server and the client is shown in Fig.12 middle.

[0155] In this embodiment, the storage and calculation methods of the model are modified based on the existing machine translation model (transformer) to reduce the physical volume and computational complexity of the model. Overall, the model is optimized from three aspects: data, server, and device, involving five optimization aspects: model computational complexity, physical storage size, and translation quality.

[0156] First, through knowledge distillation (parallel corpus is the training set corpus, which is the basic corpus for knowledge distillation), the training results of the heavyweight model are added to the data, and then the network structure of the model is optimized. The running memory of the model is further optimized through quantization, and finally the operation flow graph and the variable matrix in the network are saved to the user's device. The knowledge distillation method mainly targets the data level, with the aim of improving the translation quality of the model; lightweight word vectors, weight sharing and pruning are all aimed at reducing the number of parameters in the network, thereby reducing the physical storage volume of the model; and quantization optimizes the model for model computational efficiency; finally, through a specific storage method (such as sparse storage for sparse matrices), the model's computational flow graph and variable matrix are stored on the user's device, allowing users to break the limitations of the network and use mobile devices for real-time translation even if they are not connected to the network. Next, training is performed based on the established deep learning model to obtain model parameters. Still taking machine translation as an example, the training flowchart is shown in Fig.13 middle.

[0157] 1) First, use a pre-trained model (the pre-trained model is usually a large model with a large storage volume) to translate the training data and filter to obtain partial training data, which is used together with the original training data as the training data of the original model to be trained.

[0158] 2) Then, the matrix (SVS / bi-SVS) and layer sharing of the original model to be trained are performed, and the training data obtained in 1) is used to train the model to obtain a model with reduced storage volume.

[0159] 3) Quantize the model obtained in 2) to obtain an optimized compression model.

[0160] Since the compressed model has a reduced storage volume, it can be stored and run on a mobile device.

[0161] The embodiment of the present invention proposes a comprehensive optimization solution for generating a deep learning model suitable for mobile devices on the server side. This solution takes into account various aspects such as data, network structure, and storage optimization. On the basis of reducing the storage space of the machine translation model and accelerating the model's operating efficiency, the translation quality of the model is guaranteed as much as possible.

[0162] Fig.14 Schematically shows a block diagram of an electronic device 1400 according to an embodiment of the present invention. The electronic device 1400 includes a processor 1410, for example, a digital signal processor (DSP). The processor 1410 can be a single device or multiple devices for performing different actions according to an embodiment of the present invention. The electronic device 1400 may also include an input / output (I / O) device 1430 for receiving signals from other entities or sending signals to other entities.

[0163] In addition, the electronic device 1400 includes a memory 1420, which may be in the form of a non-volatile or volatile memory, such as an electrically erasable programmable read-only memory (EEPROM), a flash memory, etc. The memory 1420 stores computer-readable instructions, which, when executed by the processor 1410, cause the processor to perform a method according to an embodiment of the present invention.

[0164] Those skilled in the art will appreciate that the method shown above is exemplary only. The method of the present invention is not limited to the steps and sequence shown above. The device shown above can be other devices and can include more modules. The various identifiers shown above are exemplary only and not restrictive. Those skilled in the art can make many changes and modifications according to the teachings of the illustrated embodiments.

[0165] It should be understood that the above embodiments of the present invention can be implemented by software, hardware, or a combination of software and hardware. For example, various components inside the device in the above embodiments can be implemented by a variety of devices, including but not limited to: analog circuit devices, digital circuit devices, digital signal processing (DSP) circuits, programmable processors, application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), programmable logic devices (CPLDs), and the like.

[0166] In addition, the embodiments of the present invention disclosed herein can be implemented on a computer program product. More specifically, the computer program product is a product as follows: having a computer-readable medium, on which a computer program logic is encoded, and when executed on a computing device, the computer program logic provides relevant operations to implement the above-mentioned technical solution of the present invention. When executed on at least one processor of a computing system, the computer program logic causes the processor to perform the operation (method) described in the embodiment of the present invention. This arrangement of the present invention is typically provided as software, code and / or other data structures arranged or encoded on a computer-readable medium such as an optical medium (e.g., CD-ROM), a floppy disk or a hard disk, or other media such as firmware or microcode on one or more ROM or RAM or PROM chips, or downloadable software images in one or more modules, shared databases, etc. The software or firmware or such a configuration can be installed on a computing device so that one or more processors in the computing device execute the technical solution described in the embodiment of the present invention.

[0167] Although the present invention has been illustrated above in conjunction with the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that various modifications, substitutions and changes may be made to the present invention without departing from the spirit and scope of the present invention. Therefore, the present invention should not be limited by the above-described embodiments, but by the appended claims and their equivalents.

Claims

1. An optimization processing method for deep learning models, include: Adjusting the sizes of at least two matrices in the matrix of the deep learning model so that the at least two matrices have the same size; Allowing the at least two matrices to share weights; as well as Applying the deep learning model in machine translation of languages, The at least two matrices include a first matrix and a second matrix, and the adjusting the size of at least two matrices in the matrix of the deep learning model includes: Deleting word vectors from the first matrix; and / or Fill the second matrix with word vectors.

2. The optimization method according to claim 1, in, The at least two matrices include at least two of the following matrices: The word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, the parameter matrix of the output fully connected layer of the deep learning model, the word vector matrix of the encoding end after the deep learning model converts the input and output, the word vector matrix of the decoding end after the deep learning model converts the input and output, and the parameter matrix of the output fully connected layer after the deep learning model converts the input and output.

3. The optimization processing method according to claim 1, in, Deleting word vectors from the first matrix includes: According to word frequency, the word lists corresponding to the first matrix and the second matrix are sorted respectively, the size of the first matrix is ​​larger than the size of the second matrix, wherein the words in the word list corresponding to the first matrix are obtained from the first training set data, and the words in the word list corresponding to the second matrix are obtained from the second training set data, the word frequency of the words in the word list corresponding to the first matrix is ​​obtained by counting the first training set data, and the word frequency of the words in the word list corresponding to the second matrix is ​​obtained by counting the second training set data; According to the word frequency, delete the words in the word list corresponding to the first matrix after sorting, so that the size of the first matrix after deletion is the same as the size of the second matrix; Filling the word vectors into the second matrix includes: According to word frequency, the word lists corresponding to the first matrix and the second matrix are sorted respectively, the size of the first matrix is ​​larger than the size of the second matrix, wherein the words in the word list corresponding to the first matrix are obtained from the first training set data, and the words in the word list corresponding to the second matrix are obtained from the second training set data, the word frequency of the words in the word list corresponding to the first matrix is ​​obtained by counting the first training set data, and the word frequency of the words in the word list corresponding to the second matrix is ​​obtained by counting the second training set data; According to the word frequency, the identifiers are filled into the word list corresponding to the second matrix, so that the size of the filled second matrix is ​​the same as the size of the first matrix.

4. The optimization method according to any one of claims 1 to 3, in, The at least two matrices are made to share weights, comprising: Determining the shared characteristic dimension of the at least two matrices according to the set sharing rate; The at least two matrices are made to share weights at the shared feature dimension.

5. The optimization method according to claim 4, in, The sharing rate is a real number greater than 0 and less than or equal to 1.

6. The optimization method according to claim 5, in, The at least two matrices are made to share weights, comprising: According to a set first sharing rate 1, the weights of the at least two matrices are shared at all feature dimensions to obtain a first weight sharing matrix; According to the set second sharing rate, the first weight sharing matrix and at least one other matrix share weights at a shared feature dimension determined by the second sharing rate; Among them, the at least one other matrix includes other matrices in the deep learning model except for the at least two matrices used to obtain the first weight sharing matrix and / or other weight sharing matrices obtained by weight sharing.

7. The optimization method according to claim 5, in, The at least two matrices are made to share weights, comprising: According to the set first sharing rate 1, at least two matrices of the word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, and the transpose of the parameter matrix of the output fully connected layer of the deep learning model are made equal to obtain a second weight sharing matrix; According to the set first sharing rate 1, at least two matrices of the word vector matrix of the encoding end after the deep learning model input and output conversion, the word vector matrix of the decoding end after the deep learning model input and output conversion, and the transpose of the parameter matrix of the output fully connected layer after the deep learning model input and output conversion are equal to obtain a third weight sharing matrix; According to the set second sharing ratio, the second weight sharing matrix and the third weight sharing matrix are made equal at the shared feature dimension determined by the second sharing ratio.

8. The optimization method according to any one of claims 1 to 3, further comprising: include: During the generation of the deep learning model, at least one of the following methods is used for optimization: Filtering the data set output by the pre-training model, and adding the filtered data set to the training set as the training set of the deep learning model; Make the word vectors of similar words in the word vector table of the deep learning model share row vectors and / or column vectors; Making different network layers with the same structure in the deep learning model share the same parameters; Setting the weights of the model parameters of the deep learning model that are close to zero to zero; The model parameters are stored in a sparse matrix storage manner; The model parameters of the deep learning model are quantized into a set type.

9. An optimization processing device for a deep learning model, include: An adjustment module, configured to adjust the sizes of at least two matrices in the matrix of the deep learning model so that the at least two matrices have the same size; A sharing module is configured to enable the at least two matrices to share weights, Module for applying said deep learning model in machine translation of languages The at least two matrices include a first matrix and a second matrix, and the adjustment module is configured to adjust the size of at least two matrices in the matrix of the deep learning model in the following manner: Deleting word vectors from the first matrix; and / or Fill the second matrix with word vectors.

10. The optimization processing device according to claim 9, in, The at least two matrices include at least two of the following matrices: The word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, the parameter matrix of the output fully connected layer of the deep learning model, the word vector matrix of the encoding end after the deep learning model converts the input and output, the word vector matrix of the decoding end after the deep learning model converts the input and output, and the parameter matrix of the output fully connected layer after the deep learning model converts the input and output.

11. The optimization processing device according to claim 9, in, The adjustment module is configured to delete word vectors from the first matrix in the following manner: According to word frequency, the word lists corresponding to the first matrix and the second matrix are sorted respectively, the size of the first matrix is ​​larger than the size of the second matrix, wherein the words in the word list corresponding to the first matrix are obtained from the first training set data, and the words in the word list corresponding to the second matrix are obtained from the second training set data, the word frequency of the words in the word list corresponding to the first matrix is ​​obtained by counting the first training set data, and the word frequency of the words in the word list corresponding to the second matrix is ​​obtained by counting the second training set data; According to the word frequency, delete the words in the word list corresponding to the first matrix after sorting, so that the size of the first matrix after deletion is the same as the size of the second matrix; The adjustment module is configured to fill the word vectors in the second matrix in the following manner: According to word frequency, the word lists corresponding to the first matrix and the second matrix are sorted respectively, the size of the first matrix is ​​larger than the size of the second matrix, wherein the words in the word list corresponding to the first matrix are obtained from the first training set data, and the words in the word list corresponding to the second matrix are obtained from the second training set data, the word frequency of the words in the word list corresponding to the first matrix is ​​obtained by counting the first training set data, and the word frequency of the words in the word list corresponding to the second matrix is ​​obtained by counting the second training set data; According to the word frequency, the identifiers are filled into the word list corresponding to the second matrix, so that the size of the filled second matrix is ​​the same as the size of the first matrix.

12. The optimization processing device according to any one of claims 9 to 11, in, The sharing module is configured to enable the at least two matrices to share weights in the following manner: Determining the shared characteristic dimension of the at least two matrices according to the set sharing rate; The at least two matrices are made to share weights at the shared feature dimension.

13. The optimization processing device according to claim 12, in, The sharing rate is a real number greater than 0 and less than or equal to 1.

14. The optimization processing device according to claim 13, in, The sharing module is configured to enable the at least two matrices to share weights in the following manner: According to a set first sharing rate 1, the weights of the at least two matrices are shared at all feature dimensions to obtain a first weight sharing matrix; According to the set second sharing rate, the first weight sharing matrix and at least one other matrix share weights at a shared feature dimension determined by the second sharing rate; Among them, the at least one other matrix includes other matrices in the deep learning model except for the at least two matrices used to obtain the first weight sharing matrix and / or other weight sharing matrices obtained by weight sharing.

15. The optimization processing device according to claim 14, in, The sharing module is configured to enable the at least two matrices to share weights in the following manner: According to the set first sharing rate 1, at least two matrices of the word vector matrix of the encoding end of the deep learning model, the word vector matrix of the decoding end of the deep learning model, and the transpose of the parameter matrix of the output fully connected layer of the deep learning model are made equal to obtain a second weight sharing matrix; According to the set first sharing rate 1, at least two matrices of the word vector matrix of the encoding end after the deep learning model input and output conversion, the word vector matrix of the decoding end after the deep learning model input and output conversion, and the transpose of the parameter matrix of the output fully connected layer after the deep learning model input and output conversion are equal to obtain a third weight sharing matrix; According to the set second sharing ratio, the second weight sharing matrix and the third weight sharing matrix are made equal at the shared feature dimension determined by the second sharing ratio.

16. The optimization processing device according to any one of claims 9 to 11, further comprising a module for optimizing in at least one of the following ways during the generation process of the deep learning model: Filtering the data set output by the pre-training model, and adding the filtered data set to the training set as the training set of the deep learning model; Make the word vectors of similar words in the word vector table of the deep learning model share row vectors and / or column vectors; Making different network layers with the same structure in the deep learning model share the same parameters; Setting the weights of the model parameters of the deep learning model that are close to zero to zero; The model parameters are stored in a sparse matrix storage manner; The model parameters of the deep learning model are quantized into a set type.

17. A method of data processing, include: Using deep learning models to process user input data in language machine translation; Wherein, at least two matrices of the deep learning model have the same size and share weights, The at least two matrices include a first matrix and a second matrix, and the at least two matrices of the deep learning model are of the same size by: Deleting word vectors from the first matrix; and / or Fill the second matrix with word vectors.

18. A data processing device, include: A module for processing user input data using a deep learning model in machine translation of languages; Wherein, at least two matrices of the deep learning model have the same size and share weights, The at least two matrices include a first matrix and a second matrix, and the at least two matrices of the deep learning model are of the same size by: Deleting word vectors from the first matrix; and / or Fill the second matrix with word vectors.

19. An electronic device, include: processor; as well as A memory configured to store machine-readable instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 8 or 17.

20. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 8 or 17.

Citation Information

Patent Citations

  • Training method and decoding method of decoding feature weight of statistical machine

    CN101989260A

  • Adaptive neural network machine translation method based on unsupervised field

    CN107038159A

  • Compression method and device for deep learning model

    CN107368891A

  • Deep network compression method based on dimensional adaptation Tucker decomposition

    CN107516129A

  • Machine translation using overlapping biphrase alignments and sampling

    US20120101804A1