Model training method and apparatus, storage medium, and computer program product

By dividing the sample sequence into subsequences and obtaining related sequences, extracting features and adjusting model parameters, the problem of model training accuracy and performance improvement is solved, and better universal sequence representation and performance improvement are achieved.

WO2024183526A1PCT designated stage expired Publication Date: 2024-09-12HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/076263
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-08
Filing Date
2024-02-06
Publication Date
2024-09-12

AI Technical Summary

Technical Problem

Existing model training methods are difficult to improve the training accuracy and performance of the model, especially when manual labels are not required. Pre-trained language models are easily limited to specific sequence distributions when learning universal language representations from massive corpora.

Method used

By dividing the sample sequence into multiple subsequences, obtain multiple related sequences related to the subsequences and sample sequences from the sequence data set, use the feature extraction network to extract relevant features and sample features, and adjust the parameters of the initial model based on these features, using Train the model in a multi-scale and multi-granularity manner.

Benefits of technology

It achieves a better universal sequence representation of the model under multi-scale and multi-granularity, improves the training accuracy and performance of the model, and avoids the limitations of the model on specific sequence distributions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024076263_12092024_PF_FP_ABST
    Figure CN2024076263_12092024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of deep learning, and discloses a model training method and apparatus, a storage medium, and a computer program product. In the method, a plurality of related sequences are acquired in a multi-scale and multi-granularity manner by division into subsequences, the related sequences are richer, a model is trained on the basis of the rich related sequences, so that the model is not prone to being limited to a specific sequence distribution, learning of better general sequence representation by the model is facilitated, and the training accuracy and performance of the model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Model training method, device, storage medium and computer program product

[0001] This application claims priority to Chinese patent application number 202310248134.4, filed on March 8, 2023, entitled “Model training method, device, storage medium and computer program product”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of deep learning technology, and in particular to a model training method, device, storage medium and computer program product. Background Art

[0003] With the development of artificial intelligence (AI), various AI models (models for short) have been applied to various industries. Taking the pre-trained language model (PLM, referred to as pre-trained model) as an example, the PLM can learn general language representation from massive corpus without manual labeling, thereby providing services for downstream tasks. Downstream tasks include general language understanding evaluation (GLUE), question answering, sentiment analysis, named entity recognition, machine translation, and text summarization. Before the model is applied, it is usually necessary to train the model so that the trained model can better serve various industries. How to train the model to improve the training accuracy and performance of the model is a hot research topic in the industry.

[0004] Summary of the Invention

[0005] This application provides a model training method, device, storage medium, and computer program product that can improve the training accuracy and performance of the model. The technical solution is as follows:

[0006] In a first aspect, a model training method is provided, the method comprising:

[0007] A first sample sequence is divided into multiple subsequences, and the first sample sequence is used to train an initial model; multiple related sequences are obtained from a sequence data set, and the multiple related sequences include a sequence related to each subsequence in the multiple subsequences and a sequence related to the first sample sequence; feature extraction is performed on the multiple related sequences to obtain related features, and feature extraction is performed on the first sample sequence to obtain sample features; and parameters of the initial model are adjusted based on the related features and the sample features.

[0008] By dividing the subsequences, we can obtain multiple related sequences at multiple scales and granularities. The related sequences are richer. Training the model based on rich related sequences is less likely to limit the model to a specific sequence distribution, which is conducive to the model learning better general sequence representation and improving the model's training accuracy and performance.

[0009] Optionally, dividing the first sample sequence into a plurality of subsequences includes: dividing the first sample sequence into a plurality of subsequences through N rounds according to a bisection method, the number of the plurality of subsequences being N is an integer not less than 1.

[0010] Optionally, obtaining a sequence related to the first sample sequence from the sequence dataset includes: obtaining a sequence related to the first sample sequence from the sequence dataset by sequence comparison; inputting the first sample sequence into a feature extraction network, and outputting a first semantic feature through the feature extraction network, where the first semantic feature refers to a semantic feature of the first sample sequence; and obtaining a sequence related to the first sample sequence from the sequence dataset based on the first semantic feature and the semantic features of each sequence in the sequence dataset.

[0011] In other words, methods for obtaining sequences related to the first sample sequence include: sequence comparison and semantic feature-based methods. The sequence comparison method can be understood as utilizing the original sequence information for retrieval, i.e., a retrieval method based on non-depth information. The semantic feature-based method can be understood as utilizing the semantic features inherent in the sequence for retrieval, i.e., a retrieval method based on depth information. It should be understood that using a retrieval method that combines non-depth information with depth information to obtain sequences related to the first sample sequence can yield a rich and highly correlated set of related sequences.

[0012] Optionally, based on the first semantic feature and the semantic features of each sequence in the sequence dataset, obtaining a sequence related to the first sample sequence from the sequence dataset includes: determining the similarity between the first semantic feature and the semantic features of each sequence in the sequence dataset; and based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence dataset, obtaining a sequence related to the first sample sequence from the sequence dataset.

[0013] Optionally, obtaining sequences related to the multiple subsequences includes: obtaining, from a sequence dataset, sequences related to each of the multiple subsequences through sequence comparison; and / or inputting the multiple subsequences into a feature extraction network, outputting semantic features of each of the multiple subsequences through the feature extraction network; and obtaining, from the sequence dataset, sequences related to each subsequence based on the semantic features of each subsequence and the semantic features of each sequence in the sequence dataset. That is, for subsequences, either non-depth information or depth information can be used for retrieval, and both retrieval methods can also be used.

[0014] Optionally, the initial model includes an encoder based on a self-attention mechanism; performing feature extraction on the multiple related sequences to obtain related features includes: inputting the multiple related sequences into the encoder, and outputting the related features through the encoder.

[0015] Optionally, the initial model includes an embedding module; performing feature extraction on the first sample sequence to obtain sample features includes: inputting the first sample sequence into the embedding module, and outputting the sample features through the embedding module.

[0016] Optionally, adjusting the parameters of the initial model based on the correlation features and the sample features includes: determining a current global feature based on the correlation features and a reference global feature; fusing the current global feature with the sample feature to obtain an enhanced feature; and adjusting the parameters of the initial model based on the enhanced feature. The reference global feature is determined based on a second sample sequence, which is a sample sequence preceding a first sample sequence in a plurality of sample sequences used to train the initial model.

[0017] It should be understood that the computer device uses multiple sample sequences to train the initial model through an iterative loop. The computer device caches global features and updates them during the iterative loop. Global features represent the important features of the sample sequence learned by the initial model. In other words, the computer device can filter features and retain important features globally, which helps improve model performance.

[0018] Optionally, the initial model includes a feature fusion module based on a cross-attention mechanism; the current global feature is fused with the sample feature to obtain an enhanced feature, including: inputting the current global feature and the sample feature into the feature fusion module, and outputting the enhanced feature through the feature fusion module.

[0019] In a second aspect, a model training device is provided, which has the function of implementing the model training method described in the first aspect. The model training device includes one or more modules, which are used to implement the model training method described in the first aspect.

[0020] That is, a model training device is provided, the device comprising:

[0021] a subsequence division module, configured to divide a first sample sequence into a plurality of subsequences, wherein the first sample sequence is used to train an initial model;

[0022] an acquisition module, configured to acquire a plurality of related sequences from a sequence data set, wherein the plurality of related sequences include a sequence related to each subsequence in the plurality of subsequences and a sequence related to the first sample sequence;

[0023] a feature extraction module, configured to extract features from the plurality of related sequences to obtain related features, and to extract features from the first sample sequence to obtain sample features;

[0024] A parameter adjustment module is used to adjust the parameters of the initial model based on the relevant features and the sample features.

[0025] Optionally, the acquisition module includes:

[0026] A first acquisition submodule, configured to acquire a sequence related to the first sample sequence from the sequence dataset by sequence comparison;

[0027] a first feature extraction submodule, configured to input the first sample sequence into a feature extraction network, and output a first semantic feature through the feature extraction network, where the first semantic feature refers to a semantic feature of the first sample sequence;

[0028] The second acquisition submodule is configured to acquire, from the sequence dataset, a sequence related to the first sample sequence based on the first semantic feature and the semantic features of each sequence in the sequence dataset.

[0029] Optionally, the second acquisition submodule is specifically configured to:

[0030] Determining a similarity between the first semantic feature and the semantic features of each sequence in the sequence data set;

[0031] Based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set, a sequence related to the first sample sequence is obtained from the sequence data set.

[0032] Optionally, the initial model includes an encoder based on a self-attention mechanism;

[0033] The feature extraction module includes:

[0034] The second feature extraction submodule is configured to input the multiple related sequences into the encoder, and output the related features through the encoder.

[0035] Optionally, the initial model includes an embedding module;

[0036] The feature extraction module includes:

[0037] The third feature extraction submodule is configured to input the first sample sequence into the embedding module and output the sample features through the embedding module.

[0038] Optionally, the parameter adjustment module includes:

[0039] a determination submodule, configured to determine a current global feature based on the relevant feature and a reference global feature, wherein the reference global feature is determined based on a second sample sequence, where the second sample sequence is a sample sequence preceding the first sample sequence among multiple sample sequences, and the multiple sample sequences are used to train the initial model;

[0040] A fusion submodule, configured to fuse the current global feature with the sample feature to obtain an enhanced feature;

[0041] A parameter adjustment submodule is used to adjust the parameters of the initial model based on the enhanced features.

[0042] Optionally, the initial model includes a feature fusion module based on a cross-attention mechanism;

[0043] The fusion submodule is used to input the current global feature and the sample feature into the feature fusion module, and output the enhanced feature through the feature fusion module.

[0044] Optionally, the subsequence division module includes:

[0045] The subsequence division submodule is configured to divide the first sample sequence into the plurality of subsequences through N rounds according to the dichotomy method, where the number of the plurality of subsequences is The N is an integer not less than 1.

[0046] In a third aspect, a computer device is provided, comprising a processor and a memory, wherein the memory is used to store a program for executing the model training method provided in the first aspect, and to store data involved in implementing the model training method provided in the first aspect. The processor is configured to execute the program stored in the memory. The computer device may further include a communication bus for establishing a connection between the processor and the memory.

[0047] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, which, when executed on a computer, enables the computer to execute the model training method described in the first aspect above.

[0048] In a fifth aspect, a computer program product comprising instructions is provided, which, when run on a computer, enables the computer to execute the model training method described in the first aspect above.

[0049] The technical effects obtained in the above-mentioned second, third, fourth and fifth aspects are similar to those obtained by the corresponding technical means in the first aspect, and will not be repeated here.

[0050] The technical solution provided by this application can at least bring the following beneficial effects:

[0051] By dividing the subsequences, we can obtain multiple related sequences at multiple scales and granularities. The related sequences are richer. Training the model based on rich related sequences is less likely to limit the model to a specific sequence distribution, which is conducive to the model learning better general sequence representation and improving the model's training accuracy and performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] FIG1 is a schematic structural diagram of a computer device provided in an embodiment of the present application;

[0053] FIG2 is a flow chart of a model training method provided in an embodiment of the present application;

[0054] FIG3 is a detailed implementation flowchart based on the method shown in FIG2 provided in an embodiment of the present application;

[0055] FIG4 is a schematic structural diagram of a model training device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0057] The model architecture and business scenarios described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. A person of ordinary skill in the art will appreciate that, with the evolution of the model architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0058] Figure 1 is a schematic diagram illustrating the structure of a computer device according to an embodiment of the present application. Optionally, the computer device may be a personal computer, a physical server, a cloud server, a server cluster, etc. The computer device includes one or more processors 101, a communication bus 102, a memory 103, and one or more communication interfaces 104.

[0059] The processor 101 is a general-purpose central processing unit (CPU), a network processing processor (NP), a microprocessor, or one or more integrated circuits for implementing the solution of the present application, such as an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. Optionally, the PLD is a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0060] The communication bus 102 is used to transmit information between the above components. Optionally, the communication bus 102 is divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or one type of bus.

[0061] Optionally, the memory 103 is a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compact disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 103 exists independently and is connected to the processor 101 via the communication bus 102, or the memory 103 is integrated with the processor 101.

[0062] The communication interface 104 uses any transceiver-like device for communicating with other devices or communication networks. The communication interface 104 includes a wired communication interface and, optionally, a wireless communication interface. Examples of wired communication interfaces include Ethernet interfaces. Optionally, the Ethernet interface is an optical interface, an electrical interface, or a combination thereof. The wireless communication interface is a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.

[0063] Optionally, in some embodiments, the computer device includes multiple processors, such as processor 101 and processor 105 shown in Figure 1. Each of these processors is a single-core processor or a multi-core processor. Optionally, the processor here refers to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0064] In a specific implementation, as an embodiment, the computer device further includes an output device 106 and an input device 107. The output device 106 communicates with the processor 101 and can display information in a variety of ways. For example, the output device 106 is a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 107 communicates with the processor 101 and can receive user input in a variety of ways. For example, the input device 107 is a mouse, a keyboard, a touch screen device, or a sensor device.

[0065] In some embodiments, the memory 103 is used to store the program code 110 for executing the solution of the present application, and the processor 101 is capable of executing the program code 110 stored in the memory 103. The program code includes one or more software modules, and the computer device can implement the model training method provided in the embodiment of Figure 2 below through the processor 101 and the program code 110 in the memory 103.

[0066] FIG2 is a flowchart of a model training method provided in an embodiment of the present application, which is applied to a computer device. Optionally, the computer device includes one or more computing devices, which can become part or all of the server. Referring to FIG2 , the method includes the following steps.

[0067] Step 201: Divide a first sample sequence into multiple subsequences, and the first sample sequence is used to train an initial model.

[0068] In an embodiment of the present application, a computer device uses multiple sample sequences to train an initial model. The initial model can be a pre-trained model (PLM) or other untrained AI model. This article mainly introduces the initial model as a pre-trained model as an example. PLM refers to a model improved based on a self-attention model. Without manual labeling, PLM can learn a general language representation from a large amount of corpus to serve to improve the effect of downstream tasks.

[0069] During the model training process, the computer device divides a first sample sequence into a plurality of subsequences, wherein the first sample sequence is one of the plurality of subsequences.

[0070] Optionally, the multiple subsequences are obtained by bisection and N rounds of division, and the number of the multiple subsequences is N is an integer not less than 1. In other words, the computer device divides the first sample sequence into the multiple subsequences through N rounds according to the binary method.

[0071] For example, the first sample sequence is 'MKSTLM TASLLIL VLLSIVD YASVYAE' as shown in Figure 3, where N is 2 and the first sample sequence is denoted by S0. In the first round, S0 is evenly divided into two subsequences S1 and S2, with S1 and S2 being 'MKSTLM TASLLIL' and 'VLLSIVD YASVYAE', respectively. In the second round, S1 and S2 are evenly divided, with S1 being evenly divided into two subsequences S3 and S4, with S3 and S4 being 'MKSTLM' and 'TASLLIL', respectively. S2 is then evenly divided into two subsequences S5 and S6, with S5 and S6 being 'VLLSIVD' and 'YASVYAE', respectively. This completes the division of the first sample sequence, resulting in a total of six subsequences, S1 through S6.

[0072] Optionally, the multiple subsequences may be divided according to a three-way division, a combination of a three-way division and a two-way division, or other methods, which are not limited in the present embodiment. The combination of a two-way division and a three-way division means that the N rounds of division include at least one two-way division and one three-way division. For example, the first round is divided according to a two-way division, and the second round is divided according to a three-way division. For another example, the first round is divided according to a three-way division, and the second round is divided according to a two-way division.

[0073] It should be understood that, when using the binary division method to divide a sample sequence, if the sequence to be divided includes Q characters, and Q is an odd number, resulting in an even division, the computer device may divide the sequence to be divided into two subsequences, each with (Q-1) / 2 and (Q+1) / 2 characters. If a similar situation is encountered when dividing a sample sequence using other division methods, the computer device may perform similar processing.

[0074] For any other sample sequence among the multiple sample sequences except the first sample sequence, the computer device divides the subsequences using the same method as that used to divide the first sample sequence. Of course, the computer device may also divide the other sample sequences into subsequences using a method different from that used to divide the first sample sequence.

[0075] Step 202: Acquire a plurality of related sequences from the sequence data set, where the plurality of related sequences include a sequence related to each subsequence in the plurality of subsequences and a sequence related to the first sample sequence.

[0076] After dividing the first sample sequence into subsequences, the computer device retrieves, from the sequence dataset, sequences associated with each of the multiple subsequences, as well as sequences associated with the first sample sequence. Specifically, the computer device retrieves sequences associated with each subsequence, as well as sequences associated with the first sample sequence. There are many methods for computer device retrieval, and the retrieval method for subsequences can be the same as or different from the retrieval method for the first sample sequence.

[0077] Optionally, the method for obtaining a sequence related to the first sample sequence includes: a sequence comparison method and a method based on semantic features. Among them, the sequence comparison method can be understood as using the original information of the sequence for retrieval, that is, a retrieval method based on non-depth information. The method based on semantic features can be understood as using the semantic features contained in the sequence for retrieval, that is, a retrieval method based on depth information. It should be understood that using a retrieval method that combines non-depth information and depth information to obtain a sequence related to the first sample sequence can obtain rich and highly correlated related sequences. Of course, in other embodiments, the method for obtaining a sequence related to the first sample sequence may also include a sequence comparison method or a method based on semantic features.

[0078] To put it another way, in this embodiment of the present application, the computer device obtains a sequence related to the first sample sequence from the sequence dataset through sequence comparison. Furthermore, the computer device inputs the first sample sequence into a feature extraction network, which outputs a first semantic feature. The first semantic feature refers to a semantic feature of the first sample sequence. Based on the first semantic feature and the semantic features of each sequence in the sequence dataset, the computer device obtains a sequence related to the first sample sequence from the sequence dataset.

[0079] The computer device determines the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set, and obtains a sequence related to the first sample sequence from the sequence data set based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set.

[0080] Optionally, the computer device obtains, from the sequence data set, M sequences whose semantic features have a high degree of similarity to the first semantic feature according to the degree of similarity, to obtain a sequence related to the first sample sequence, where M is an integer not less than 0. When M is 1, the sequence obtained by the computer device has the highest degree of similarity to the semantic features of the first sample sequence, that is, the obtained sequence has the strongest correlation with the first sample sequence.

[0081] Optionally, a method for obtaining a sequence related to each of the multiple subsequences includes a sequence comparison method and / or a semantic feature-based method. That is, for a subsequence, either non-depth information or depth information can be used for retrieval, or both retrieval methods can be used.

[0082] To put it another way, in an embodiment of the present application, the computer device obtains a sequence related to each of the multiple subsequences from the sequence dataset through sequence comparison. Furthermore, the computer device inputs each of the multiple subsequences into a feature extraction network, which outputs semantic features of each of the multiple subsequences. Based on the semantic features of each subsequence and the semantic features of each sequence in the sequence dataset, the computer device obtains a sequence related to each subsequence from the sequence dataset.

[0083] The computer device determines the similarity between the semantic features of each subsequence and the semantic features of each sequence in the sequence data set, and obtains a sequence related to each subsequence from the sequence data set based on the similarity between the semantic features of each subsequence and the semantic features of each sequence in the sequence data set.

[0084] Optionally, the computer device obtains P sequences from the sequence dataset whose semantic features have a high degree of similarity with the semantic features of each subsequence, based on the degree of similarity, to obtain a sequence related to each subsequence, where P is an integer not less than 0. When P is 1, the sequence obtained by the computer device has the highest degree of similarity with the semantic features of each subsequence, i.e., the obtained sequence has the highest correlation with each subsequence. Q and M may be the same or different.

[0085] The aforementioned sequence comparison methods include single sequence comparison and multiple sequence comparison, and tools that can be used for sequence comparison include many-against-many sequence search (MMSEQ2). Semantic feature-based methods include BERT+ScaNN or other deep learning methods.

[0086] The feature extraction network can be a network included in the initial model or another network, which is not limited in this embodiment of the present application. The feature extraction network can be a convolutional neural network, an embedding module, or other types of networks, which is not limited in this embodiment of the present application.

[0087] The sequence dataset includes a training dataset and / or an external dataset. The computer device retrieves the multiple related sequences from the training dataset and / or the external dataset by searching. The training dataset includes the multiple sample sequences, while the external dataset may not include the multiple sample sequences.

[0088] Step 203: performing feature extraction on the multiple related sequences to obtain related features, and performing feature extraction on the first sample sequence to obtain sample features.

[0089] That is, the computer device performs feature extraction on the first sample sequence and the multiple retrieved related sequences. The manner in which the computer device extracts features from the first sample sequence and the multiple related sequences may be the same or different, and this embodiment of the present application is not limited thereto. Numerous feature extraction methods exist, and the following describes some feature extraction methods based on deep learning technology.

[0090] In one implementation, the initial model includes an encoder (Encoder, Enc) based on a self-attention (SA) mechanism. Based on this, the computer device extracts features from the multiple related sequences. The implementation process of obtaining relevant features includes: inputting the multiple related sequences into the encoder based on the self-attention mechanism, and having the encoder output relevant features.

[0091] The encoder based on the self-attention mechanism may be a transformer encoder (abbreviated as Trans-Enc). The embodiment of the present application does not limit the structure, number of layers, etc. of the encoder based on the self-attention mechanism.

[0092] The initial model includes an embedding module. The computer device extracts features from the first sample sequence to obtain sample features, including: inputting the first sample sequence into the embedding module, and outputting the sample features through the embedding module.

[0093] In an embodiment of the present application, the initial model includes the above-mentioned encoder based on the self-attention mechanism and an embedding module, wherein the encoder is used to extract features of the multiple related sequences, and the embedding module is used to extract features of the sample sequence.

[0094] Step 204: Based on the relevant features and sample features, adjust the parameters of the initial model.

[0095] The computer device adjusts the parameters of the initial model based on the relevant features and the sample features to train the initial model.

[0096] One implementation process for adjusting the parameters of the initial model based on the correlation features and the sample features includes: determining a current global feature based on the correlation features and a reference global feature; fusing the current global feature with the sample feature to obtain an enhanced feature; and adjusting the parameters of the initial model based on the enhanced feature. The reference global feature is determined based on a second sample sequence, which is a sample sequence preceding a first sample sequence in the multiple sample sequences used to train the initial model.

[0097] It should be understood that the computer device uses multiple sample sequences to train the initial model through an iterative loop. The computer device caches global features and updates them during the iterative loop. Global features represent the important features of the sample sequence learned by the initial model. In other words, the computer device can filter features and retain important features globally, which helps improve model performance.

[0098] When the computer device uses the previous sample sequence of the first sample sequence to train the initial model, the global features determined based on the previous sample sequence are cached (i.e., the reference global features). When the computer device uses the first sample sequence to train the initial model, the computer device can update the global features (i.e., determine the current global features) based on the relevant features and the cached global features. Similarly, when the computer device uses the next sample sequence of the first sample sequence to train the initial model, the computer device can continue to update the global features based on the features of the sequence related to the next sample sequence. In the process of determining the current global features using the first sample sequence of the multiple sample sequences, the value of the reference global features is an initial value, which can be zero.

[0099] Optionally, the computer device performs a weighted summation of the relevant feature and the reference global feature to obtain the current global feature. Alternatively, the computer device performs a weighted exponentiation of the relevant feature and the reference global feature to obtain the current global feature. Alternatively, the computer device processes the relevant feature and the reference global feature in other ways to obtain the current global feature.

[0100] Optionally, the initial model includes a feature fusion module based on a cross-attention (Cro-Att) mechanism. After obtaining the current global feature, the computer device inputs the current global feature and the sample feature into the feature fusion module, and the feature fusion module outputs the enhanced feature.

[0101] When the computer device obtains enhanced features, it can adjust the parameters of the initial model through a feed-forward method.

[0102] In one embodiment, the initial model includes a subsequence division module, a retrieval module, an encoder based on a self-attention mechanism (Trans-Enc), a global feature cache module, an embedding (abbreviated as Emb) module, a feature fusion module based on a cross-attention mechanism (Cro-Att) and a forward feedback module, etc.

[0103] The subsequence division module is used to divide the first sample sequence into multiple subsequences.

[0104] The retrieval module is used to obtain multiple related sequences from the sequence data set. The multiple related sequences include sequences related to the first sample sequence and sequences related to the multiple subsequences. Optionally, the retrieval module includes a sequence comparison submodule and a semantic feature-based retrieval submodule. The sequence comparison submodule is used to obtain sequences related to the first sample sequence from the sequence data set through sequence comparison. The semantic feature-based retrieval submodule includes a feature extraction network, and the retrieval submodule is used to obtain sequences related to the first sample sequence from the sequence data set using the feature extraction network. In addition, the sequence comparison submodule is also used to obtain sequences related to the multiple subsequences from the sequence data set through sequence comparison, and / or the semantic feature-based retrieval submodule is also used to obtain sequences related to the multiple subsequences from the sequence data set using the feature extraction network.

[0105] The encoder based on the self-attention mechanism is used to extract features from the multiple related sequences to obtain relevant features. The embedding module is used to extract features from the first sample sequence to obtain sample features.

[0106] The global feature cache module is used to determine the current global feature based on the relevant feature and the reference global feature.

[0107] The feature fusion module based on the cross-attention mechanism is used to fuse the sample features with the current global features to obtain enhanced features. The forward feedback module is used to adjust the parameters of the pre-trained model based on the enhanced features.

[0108] FIG3 is a detailed implementation flow chart of the above method provided in an embodiment of the present application.

[0109] In Figure 3, the initial model is a pre-trained model. This pre-trained model is based on the general pre-trained language model (generative pre-trained transformer-3, GPT3) as the main architecture, and the retrieval and feature fusion functions in this main architecture are improved. This pre-trained model includes a subsequence partitioning module, a retrieval module, an encoder based on the self-attention mechanism (Trans-Enc), a global feature cache module, an embedding module (abbreviated as Embb), a feature fusion module based on the cross-attention mechanism (Cro-Att), and a forward feedback module.

[0110] The subsequence division module is used to divide the first sample sequence S0 into six subsequences S1 to S6 in two rounds according to the binary division method.

[0111] The retrieval module is used to obtain multiple related sequences from the sequence data set. The multiple related sequences include sequences related to the first sample sequence S0, and sequences related to the six subsequences S1 to S6. Optionally, the retrieval module includes a sequence comparison submodule and a retrieval submodule based on semantic features. The sequence comparison submodule is used to obtain sequences related to the first sample sequence S0 from the sequence data set through sequence comparison. The retrieval submodule based on semantic features includes a feature extraction network, and the retrieval submodule is used to obtain sequences related to the first sample sequence S0 from the sequence data set using the feature extraction network. In addition, the sequence comparison submodule is also used to obtain sequences related to the six subsequences from the sequence data set through sequence comparison, and / or the retrieval submodule based on semantic features is also used to obtain sequences related to the six subsequences from the sequence data set using the feature extraction network.

[0112] For example, the computer device uses the sequence comparison submodule to obtain a sequence related to each of sequences S0 to S6 from the sequence dataset, and uses the semantic feature-based retrieval submodule to obtain another sequence related to each of sequences S0 to S6 from the sequence dataset. Thus, the computer device obtains a total of 14 related sequences.

[0113] The encoder based on the self-attention mechanism is used to extract features from the multiple related sequences to obtain relevant features.

[0114] For example, the computer device inputs the 14 related sequences (i.e., retrieved sequences) into the encoder, and the encoder outputs the related features (Feat). This process can be expressed by formula (1). Feat = Encoder (retrieved sequences) (1)

[0115] The embedding module is used to extract features from the first sample sequence to obtain sample features.

[0116] The global feature cache module is used to determine the current global feature based on the relevant feature and the reference global feature.

[0117] For example, the reference global feature is recorded as memory i-1 , the relevant features are recorded as Feat, and the current global features are recorded as memory i The computer device can determine the current global feature by weighted summation according to formula (2). In formula (2), alpha represents the weight of the weighted summation, and the value range of alpha can be (0,1). i =alpha*Feat+(1-alpha)*memory i-1 (2)

[0118] The feature fusion module based on the cross-attention mechanism is used to fuse sample features and current global features to obtain enhanced features.

[0119] For example, the sample feature is recorded as feat -S0 , the computer equipment can use formula (3) to calculate feat -S0 and memory i Perform the same fusion to obtain the enhanced feature (fusion_feat). fusion_feat = cross-attention (feat -S0 ,memory i ) (3)

[0120] The cross-attention in formula (3) can be expressed using formulas (4) to (7). fusion_feat=W(QK T )V (7)

[0121] The feedforward module is used to adjust the parameters of the pre-trained model based on the enhanced features.

[0122] In the embodiment of the present application, the encoder based on the self-attention mechanism includes hidden layers. The more hidden layers there are, the better the performance of the model training is. The fewer hidden layers there are, the faster the model training is.

[0123] The model training method provided in the embodiments of this application can be applied to pre-trained language models across various industries, and is particularly useful in downstream tasks and / or scenarios where high-value data is scarce in the training dataset. For example, this method can be applied in the field of biology, where protein sequences are input as sample sequences into a pre-trained language model to train the pre-trained language model, which can then be used to generate new protein sequences.

[0124] In summary, in the embodiments of the present application, by dividing the subsequences, it is possible to obtain multiple related sequences at multiple scales and granularities, and the related sequences are richer. Training the model based on the rich related sequences does not easily limit the model to a specific sequence distribution, which is conducive to the model learning a better general sequence representation and improving the training accuracy and performance of the model. Among them, for the sample sequence, related sequence retrieval can be performed by combining depth information and non-depth information. Subsequently, feature fusion is performed by updating the global features, and the fused enhanced features are forwarded. This can globally retain the important features learned by the model, thereby improving the convergence ability of the initial model.

[0125] FIG4 is a schematic diagram of the structure of a model training device 400 provided in an embodiment of the present application. The model training device 400 can be implemented as part or all of a computer device using software, hardware, or a combination of both. The computer device can be the computer device described in the above embodiments. Referring to FIG4 , the model training device 400 includes a subsequence partitioning module 401, an acquisition module 402, a feature extraction module 403, and a parameter adjustment module 404.

[0126] A subsequence division module 401 is configured to divide a first sample sequence into a plurality of subsequences, where the first sample sequence is used to train an initial model;

[0127] An acquisition module 402 is configured to acquire a plurality of related sequences from a sequence data set, wherein the plurality of related sequences include a sequence related to each subsequence in the plurality of subsequences and a sequence related to the first sample sequence;

[0128] A feature extraction module 403 is configured to extract features from the multiple related sequences to obtain related features, and to extract features from the first sample sequence to obtain sample features;

[0129] The parameter adjustment module 404 is used to adjust the parameters of the initial model based on the relevant features and sample features.

[0130] Optionally, the acquisition module 402 includes:

[0131] A first acquisition submodule is used to acquire a sequence related to the first sample sequence from the sequence data set by sequence comparison;

[0132] A first feature extraction submodule is configured to input the first sample sequence into a feature extraction network, and output a first semantic feature through the feature extraction network, where the first semantic feature refers to a semantic feature of the first sample sequence;

[0133] The second acquisition submodule is configured to acquire, from the sequence dataset, a sequence related to the first sample sequence based on the first semantic feature and the semantic features of each sequence in the sequence dataset.

[0134] Optionally, the second acquisition submodule is specifically configured to:

[0135] Determining a similarity between the first semantic feature and the semantic features of each sequence in the sequence dataset;

[0136] Based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence dataset, a sequence related to the first sample sequence is obtained from the sequence dataset.

[0137] Optionally, the initial model includes an encoder based on a self-attention mechanism;

[0138] The feature extraction module 403 includes:

[0139] The second feature extraction submodule is used to input the multiple related sequences into an encoder, and output related features through the encoder.

[0140] Optionally, the initial model includes an embedding module;

[0141] The feature extraction module 403 includes:

[0142] The third feature extraction submodule is used to input the first sample sequence into the embedding module and output sample features through the embedding module.

[0143] Optionally, the parameter adjustment module 404 includes:

[0144] a determination submodule, configured to determine a current global feature based on the relevant feature and a reference global feature, where the reference global feature is determined based on a second sample sequence, where the second sample sequence is a sample sequence preceding the first sample sequence in the multiple sample sequences, and the multiple sample sequences are used to train the initial model;

[0145] The fusion submodule is used to fuse the current global features with the sample features to obtain enhanced features;

[0146] The parameter adjustment submodule is used to adjust the parameters of the initial model based on the enhanced features.

[0147] Optionally, the initial model includes a feature fusion module based on a cross-attention mechanism;

[0148] The fusion submodule is used to input the current global features and sample features into the feature fusion module, and output the enhanced features through the feature fusion module.

[0149] Optionally, the subsequence division module 401 includes:

[0150] The subsequence division submodule is used to divide the first sample sequence into the multiple subsequences through N rounds according to the dichotomy method. The number of the multiple subsequences is N is an integer not less than 1.

[0151] In an embodiment of the present application, by dividing the subsequences, multiple related sequences can be obtained at multiple scales and granularities, and the related sequences are richer. Training the model based on the rich related sequences does not easily limit the model to a specific sequence distribution, which is conducive to the model learning a better general sequence representation, thereby improving the training accuracy and performance of the model.

[0152] It should be noted that the model training device provided in the above embodiment only uses the division of the above functional modules as an example when training the model. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the model training device provided in the above embodiment and the model training method embodiment are of the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0153] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.

[0154] It should be understood that the "at least one" mentioned herein refers to one or more, and "a plurality of" refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate a clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0155] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the sample sequences involved in the embodiments of this application were all obtained with full authorization.

[0156] The above description is an embodiment provided for this application and is not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application should be included in the scope of protection of this application.

Claims

1. A model training method, characterized in that: The method comprises: Dividing a first sample sequence into a plurality of subsequences, wherein the first sample sequence is used to train an initial model; Acquire a plurality of related sequences from a sequence data set, wherein the plurality of related sequences include a sequence related to each subsequence in the plurality of subsequences and a sequence related to the first sample sequence; Extracting features from the multiple related sequences to obtain related features, and extracting features from the first sample sequence to obtain sample features; Based on the relevant features and the sample features, the parameters of the initial model are adjusted.

2. The method according to claim 1, characterized in that Acquiring a sequence related to the first sample sequence from the sequence data set includes: Acquire a sequence related to the first sample sequence from the sequence data set by sequence comparison; Inputting the first sample sequence into a feature extraction network, and outputting a first semantic feature through the feature extraction network, where the first semantic feature refers to a semantic feature of the first sample sequence; Based on the first semantic feature and the semantic features of each sequence in the sequence data set, a sequence related to the first sample sequence is acquired from the sequence data set.

3. The method according to claim 2, characterized in that The acquiring, from the sequence data set, a sequence related to the first sample sequence based on the first semantic feature and the semantic features of each sequence in the sequence data set, includes: Determining the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set; Based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set, a sequence related to the first sample sequence is obtained from the sequence data set.

4. The method according to any one of claims 1 to 3, characterized in that: The initial model includes an encoder based on a self-attention mechanism; The extracting features from the multiple related sequences to obtain related features includes: The multiple correlation sequences are input into the encoder, and the encoder outputs the correlation features.

5. The method according to any one of claims 1 to 4, characterized in that: The initial model includes an embedding module; The extracting features from the first sample sequence to obtain sample features includes: The first sample sequence is input into the embedding module, and the sample features are output through the embedding module.

6. The method according to any one of claims 1 to 5, characterized in that: The adjusting the parameters of the initial model based on the relevant features and the sample features includes: Determine a current global feature based on the relevant feature and a reference global feature, wherein the reference global feature is determined based on a second sample sequence, wherein the second sample sequence is a previous sample sequence of the first sample sequence among multiple sample sequences, and the multiple sample sequences are used to train the initial model; The current global feature is merged with the sample feature to obtain an enhanced feature; Based on the enhanced features, parameters of the initial model are adjusted.

7. The method according to claim 6, characterized in that The initial model includes a feature fusion module based on a cross-attention mechanism; The fusing the current global feature with the sample feature to obtain an enhanced feature includes: The current global feature and the sample feature are input into the feature fusion module, and the enhanced feature is output through the feature fusion module.

8. The method according to any one of claims 1 to 7, characterized in that: The step of dividing the first sample sequence into a plurality of subsequences comprises: According to the binary search method, the first sample sequence is divided into the multiple subsequences through N rounds, and the number of the multiple subsequences is The N is an integer not less than 1.

9. A model training device, characterized in that: The device comprises: A subsequence division module, used to divide a first sample sequence into a plurality of subsequences, wherein the first sample sequence is used to train an initial model; An acquisition module, configured to acquire a plurality of related sequences from a sequence data set, wherein the plurality of related sequences include a sequence related to each subsequence in the plurality of subsequences and a sequence related to the first sample sequence; A feature extraction module, configured to extract features from the multiple related sequences to obtain related features, and to extract features from the first sample sequence to obtain sample features; A parameter adjustment module is used to adjust the parameters of the initial model based on the relevant features and the sample features.

10. The device according to claim 9, characterized in that The acquisition modules include: A first acquisition submodule, configured to acquire a sequence related to the first sample sequence from the sequence data set by sequence comparison; A first feature extraction submodule, configured to input the first sample sequence into a feature extraction network, and output a first semantic feature through the feature extraction network, where the first semantic feature refers to a semantic feature of the first sample sequence; The second acquisition submodule is configured to acquire a sequence related to the first sample sequence from the sequence data set based on the first semantic feature and the semantic features of each sequence in the sequence data set.

11. The device according to claim 10, characterized in that The second acquisition submodule is specifically used for: Determining the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set; Based on the similarity between the first semantic feature and the semantic features of each sequence in the sequence data set, a sequence related to the first sample sequence is obtained from the sequence data set.

12. The device according to any one of claims 9 to 11, characterized in that: The initial model includes an encoder based on a self-attention mechanism; The feature extraction module comprises: The second feature extraction submodule is used to input the multiple related sequences into the encoder, and output the related features through the encoder.

13. The device according to any one of claims 9 to 12, characterized in that: The initial model includes an embedding module; The feature extraction module comprises: The third feature extraction submodule is used to input the first sample sequence into the embedding module, and output the sample features through the embedding module.

14. The device according to any one of claims 9 to 13, characterized in that: The parameter adjustment module includes: a determination submodule, configured to determine a current global feature based on the relevant feature and a reference global feature, wherein the reference global feature is determined based on a second sample sequence, wherein the second sample sequence is a previous sample sequence of the first sample sequence among multiple sample sequences, and the multiple sample sequences are used to train the initial model; A fusion submodule, used for fusing the current global feature with the sample feature to obtain an enhanced feature; A parameter adjustment submodule is used to adjust the parameters of the initial model based on the enhanced features.

15. The device according to claim 14, characterized in that The initial model includes a feature fusion module based on a cross-attention mechanism; The fusion submodule is used to input the current global feature and the sample feature into the feature fusion module, and output the enhanced feature through the feature fusion module.

16. The device according to any one of claims 9 to 15, characterized in that: The subsequence division module comprises: The subsequence division submodule is used to divide the first sample sequence into the multiple subsequences through N rounds according to the binary method. The number of subsequences is The N is an integer not less than 1.

17. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the methods of claims 1-8 are implemented.

18. A computer program product, characterized in that The computer program product stores computer instructions, and when the computer instructions are executed by a processor, the steps of any one of the methods of claims 1-8 are implemented.

Citation Information

Patent Citations

  • Model training method and device for determining text relevancy, electronic equipment and readable storage medium

    CN111832290A

  • Text mapping model processing method and device, computer equipment and storage medium

    CN114328815A

  • Language model training method, text matching method and related device

    CN114626463A

  • Model training method and device and task execution method and device

    CN115017915A

  • Language representation model system, pre-training method and apparatus, device and medium

    WO2022022421A1