Model training method and device, computer device, and storage medium
By training a feature extraction model through generative self-supervised learning and adjacent sequence comparison learning, the problem of feature information extraction in user interaction behavior is solved, and more accurate user profiles and personalized services are achieved.
Patent Information
- Application Number
- CN202211586217.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-09
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2042-12-09
AI Technical Summary
Existing technologies struggle to effectively extract feature information from user interaction behavior, making it impossible to accurately build user profiles and provide personalized services.
The prediction of the distribution of events in adjacent sequences is used as the objective function of generative self-supervised learning. Adjacent sequence comparison learning is used as a self-supervised signal to train the feature extraction model. The robustness and generalization ability of the model are improved by cross-prediction of adjacent sequences.
It improves the robustness and generalization ability of the feature extraction model, enabling it to extract more accurate event-level fine-grained and sequence-level information, thereby improving the accuracy of user profiles and the provision of personalized services.
Smart Images

Figure CN116304665B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a model training method and device, a computer device, and a storage medium. BACKGROUND
[0002] With the continuous development and progress of technology, more and more terminal devices enter the public view. The operation of a user on a terminal device will leave rich interactive behaviors, such as APP startup behaviors. Based on this, how to better extract effective information from interactive behaviors and use the effective information to perform user portrait on the user to help a device manufacturer to provide more appropriate personalized services for the user has become a problem to be solved at present. SUMMARY
[0003] The present application provides a model training method and device, a computer device, and a storage medium to improve the ability of extracting feature information through a feature extraction model.
[0004] In a first aspect, an embodiment of the present application provides a model training method, which includes: obtaining a training sample set, the training sample set including multiple pairs of sample behavior data sequences, each pair of sample behavior data sequences including a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, and each pair of sample behavior data sequences carrying a target label, the target label being used to represent the distribution of sample behavior data in the sample behavior data sequence; inputting each pair of sample behavior data sequences into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence; determining a first loss value based on the similarity between the first sample feature sequence and the second sample feature sequence; determining a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent the difference between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and the difference between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence; performing iterative training on the first initial model based on the first loss value and the second loss value until a first target condition is met, to obtain a trained first initial model as a feature extraction model.
[0005] In a second aspect, an embodiment of the present application provides a model training apparatus, the apparatus comprising: a training sample acquisition module, a feature sequence extraction module, a first loss value determination module, a second loss value determination module, and a model training module. The training sample acquisition module is configured to acquire a training sample set, the training sample set comprising a plurality of pairs of sample behavior data sequences, each pair of sample behavior data sequences comprising a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, each pair of sample behavior data sequences carrying a target label, the target label being configured to represent a distribution of sample behavior data in the sample behavior data sequence; the feature sequence extraction module is configured to input each pair of sample behavior data sequences into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence; the first loss value determination module is configured to determine a first loss value based on a similarity between the first sample feature sequence and the second sample feature sequence; the second loss value determination module is configured to determine a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being configured to represent a difference degree between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and a difference degree between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence; and the model training module is configured to iteratively train the first initial model based on the first loss value and the second loss value until a first target condition is met, to obtain a trained first initial model as a feature extraction model.
[0006] In a third aspect, an embodiment of the present application provides a computer device, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to perform the method described above.
[0007] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium storing program codes, the program codes being executable by a processor to perform the method described above.
[0008] In the scheme provided in the application, a training sample set is obtained, wherein the training sample set includes multiple pairs of sample behavior data sequences, each pair of sample behavior data sequences includes a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, and each pair of sample behavior data sequences carries a target label, which is used to represent the distribution of sample behavior data in the sample behavior data sequence; each pair of sample behavior data sequences is input into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence; a first loss value is determined based on the similarity between the first sample feature sequence and the second sample feature sequence; a second loss value is determined based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent the difference between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and the difference between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence; the first initial model is iteratively trained based on the first loss value and the second loss value until a first target condition is met, and the trained first initial model is obtained as a feature extraction model. In this way, the event distribution in the adjacent behavior data sequence is predicted for training the feature extraction model using the generative self-supervised learning as the objective function, and the adjacent sequence contrast learning is used as the self-supervised signal. In this way, the data input based on the adjacent sequence naturally meets the combination requirement, effectively alleviating the sample processing complexity; the feature extraction model obtained by training combines the ability of the generative self-supervised learning to model event-level fine-grained information and the ability of the contrast task to model sequence-level information; at the same time, the adjacent sequence cross-prediction improves the robustness and generalization ability of the sequence representation, and the self-supervised learning based on distribution prediction effectively improves the ability to extract event sequence statistical information and co-occurrence information, and alleviates the influence of random events. BRIEF DESCRIPTION OF DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0010] Figure 1 A flowchart of a model training method provided by an embodiment of the present application is shown.
[0011] Figure 2A schematic diagram of positive and negative sample pairs provided in an embodiment of this application is shown.
[0012] Figure 3 It shows Figure 1 A flowchart illustrating a sub-step of step S140 in one embodiment.
[0013] Figure 4 It shows Figure 1 A flowchart illustrating a sub-step of step S150 in one embodiment.
[0014] Figure 5 A schematic flowchart of a model training method provided in another embodiment of this application is shown.
[0015] Figure 6 It shows Figure 5 A flowchart illustrating a sub-step of step S230 in one embodiment.
[0016] Figure 7 It shows Figure 6 A flowchart illustrating a sub-step of step S233 in one embodiment.
[0017] Figure 8 A schematic diagram of the model network architecture of the first initial model provided in an embodiment of this application is shown.
[0018] Figure 9 This diagram illustrates the feature flow direction of the encoding module performing feature extraction according to an embodiment of this application.
[0019] Figure 10 This is a block diagram of a model training device according to an embodiment of this application.
[0020] Figure 11 This is a block diagram of a computer device for performing a model training method according to an embodiment of this application.
[0021] Figure 12 This is a storage unit in this application embodiment for storing or carrying program code that implements the model training method according to this application embodiment. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0023] It should be noted that in some of the processes described in this specification, including the description of the flow diagrams, blocks and steps of the processes are described in a particular order. These blocks and steps should be understood as not necessarily being limited to the order in which they are presented. The order of execution of the blocks and steps can be changed, and some blocks and steps can be performed in parallel or in series. The sequence of blocks and steps should not be understood as necessarily representing a sequence of steps executed in the particular order presented, unless specifically stated otherwise. Furthermore, some blocks and steps can be performed simultaneously. The description herein of a process or method including blocks and steps should not be understood as necessarily requiring that all of the blocks and steps are performed in the particular order presented, unless specifically stated as such. The sequence of blocks and steps should not be understood as necessarily representing a sequence of steps executed in the particular order presented, unless specifically stated otherwise. Furthermore, some blocks and steps can be performed simultaneously. The description herein of a process or method including blocks and steps should not be understood as necessarily requiring that all of the blocks and steps are performed in the particular order presented, unless specifically stated as such.
[0024] The inventors propose a model training method, device, computer equipment and storage medium, which uses the prediction of adjacent sequence event distribution as the objective function of generative self-supervised learning, and uses adjacent sequence contrast learning as a self-supervised signal to train a feature extraction model. The model training method provided by the embodiments of the present application will be described in detail below.
[0025] Please refer to Figure 1 , Figure 1 A flowchart of a model training method provided by an embodiment of the present application is shown below. The model training method provided by the embodiments of the present application will be described in detail below. Figure 1 The model training method can include the following steps:
[0026] Step S110: Obtain a training sample set, the training sample set including a plurality of pairs of sample behavior data sequences, each pair of sample behavior data sequences including a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, each pair of sample behavior data sequences carrying a target label, the target label being used to represent the distribution of sample behavior data in the sample behavior data sequence.
[0027] In the embodiment, the training sample set can be obtained from an open source sample set, or can be constructed based on a large amount of sample behavior data set crawled by itself, and the embodiment does not limit this. The training sample set includes a plurality of pairs of sample behavior data sequences, and the plurality of pairs of sample behavior data sequences include positive sample pairs and negative sample pairs; the first period and the second period have equal period lengths, which are pre-set values, for example, two weeks, three weeks or a month, etc. In this way, the length of the training sample used for model training can be avoided to be inconsistent, and the training effect of the model can be affected.
[0028] Optionally, the first sample behavior data sequence includes an event sequence generated by a user operating a terminal device in the first period, and the second sample behavior data sequence includes an event sequence generated by the user operating the terminal device in the second period adjacent to the first period. The event sequence includes, but is not limited to, context information such as a start time of an application (APP) recorded by the user operating the terminal device, a duration of a current use of the APP, and auxiliary information such as an APP category; or is information such as a click sequence and a purchase sequence of the user in a shopping software on the terminal device, and the embodiment does not limit this. If the first sample behavior data sequence and the second sample behavior data sequence are event sequences generated by the same user operating the terminal device in the first period and the second period, the first sample behavior data sequence and the second sample behavior data sequence are the positive sample pairs mentioned above. If the first sample behavior data sequence and the second sample behavior data sequence are event sequences generated by two different users operating the terminal device in the first period and the second period, the first sample behavior data sequence and the second sample behavior data sequence constitute the negative sample pairs mentioned above.
[0029] Each sample behavior data sequence carries a target label used to represent a distribution of sample behavior data in the sample behavior data sequence. That is, the target label includes a probability value corresponding to each sample behavior data. Taking the sample behavior data sequence as an example, the first sample behavior data sequence includes an event sequence generated by sequentially operating APP1, APP2 and APP3, and the distribution of sample behavior data is the probability distribution of the user operating APP1, APP2 and APP3 in the first period.
[0030] For example, in combination with the above-mentioned embodiments, the target label can be a probability value corresponding to each sample behavior data. Figure 2Taking the sample behavior data sequence as an APP sequence as an example, a plurality of pairs of sample behavior data sequences in the training sample set are described. The APP sequence T11 and the APP sequence T12 are two APP sequences generated by the terminal device operated by the user 1 in the first period and the second period adjacent to the first period, and the APP sequence T21 and the APP sequence T22 are two APP sequences generated by the terminal device operated by the user 1 in the first period and the second period adjacent to the first period. It can be seen that the APP sequence T11 and the APP sequence T12 generated by the terminal device operated by the user 1 are a positive sample pair in the training sample set, and the APP sequence T11 and the APP sequence T12 carry target labels respectively, and the target labels include the probability distribution of all APPs in each APP sequence. Similarly, the APP sequence T21 and the APP sequence T22 generated by the terminal device operated by the user 2 are also a positive sample pair in the training sample set, the APP sequence T11 generated by the terminal device operated by the user 1 and the APP sequence T22 generated by the terminal device operated by the user 2 constitute a negative sample pair, and the APP sequence T12 generated by the terminal device operated by the user 1 and the APP sequence T21 generated by the terminal device operated by the user 2 also constitute a negative sample pair.
[0031] Step S120: input each pair of the sample behavior data sequences into the first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence.
[0032] In this embodiment, the first initial model is an untrained network model for extracting features from data sequences, and needs to be trained by a large number of sample behavior data to improve the ability of extracting features. Based on this, each pair of sample behavior data sequences can be input into the first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence.
[0033] Step S130: determining a first loss value based on the similarity between the first sample feature sequence and the second sample feature sequence.
[0034] It can be understood that, since the first sample feature sequence and the second sample feature sequence are feature sequences in adjacent periods, and in actual application, the APP sequence started by the user reflects the slowly changing interests and habits of the user, the interest similarity embodied by the adjacent sample feature sequences of the same user is greater than the interest similarity between the non-adjacent sample feature sequences and the adjacent sample feature sequences obtained by operation of two different users. Therefore, the similarity between the first sample feature sequence and the second sample feature sequence can be calculated in a contrast learning manner, and whether the first sample behavior data sequence and the second sample behavior data sequence are from the behavior data sequences of the same user in adjacent periods is determined based on the similarity.
[0035] Optionally, the following loss function of contrast learning can be used to calculate the first loss value.
[0036]
[0037] wherein N is the number of samples input into the first initial model in the same batch, O i is a sequence representation, τ is an adjustment coefficient, I[i≠j] is an indicator function, when i≠j, the function value of the indicator function is 1, and when i=j, the function value of the indicator function is 0, and sim is a similarity evaluation function. Optionally, the similarity evaluation function can use the following cosine similarity evaluation function:
[0038]
[0039] Of course, the similarity evaluation function can also use Euclidean distance, Hamming distance, Manhattan distance, Chebyshev distance, Jaccard index, half-sine, etc. The present embodiment is not limited in this regard.
[0040] It can be seen that the first loss value determined by the contrast learning of the adjacent sample behavior data sequences is used as a self-supervised signal, which can improve the ability of the first initial model to model sequence-level information.
[0041] Step S140: determining a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent the difference between the first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and the difference between the second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence.
[0042] In some embodiments, please refer to Figure 3Step S140 can include the contents in steps S141-S145:
[0043] Step S141: determining the first prediction label corresponding to the second sample behavior data sequence based on the first sample feature sequence.
[0044] In this embodiment, after the first sample feature sequence and the second sample feature sequence are extracted, label prediction can be performed by using a pre-trained label prediction model. Specifically, the first sample feature sequence is input into the label prediction model, and the label prediction model can predict the distribution of the sample behavior data in the second sample behavior data sequence of the second period adjacent to the first sample feature sequence according to the behavior feature information contained in the first sample feature sequence, as the first prediction label corresponding to the second sample behavior data sequence.
[0045] Step S142: determining the third loss value based on the difference between the first prediction label and the target label corresponding to the second sample behavior data sequence.
[0046] It can be understood that, since the first sample behavior data sequence and the second sample behavior data sequence are sequence pairs of adjacent periods, the similarity between the first sample feature sequence and the second sample feature sequence is also high. Based on this, if the feature extraction capability of the first initial model is good, the first prediction label corresponding to the second sample behavior data sequence determined based on the first sample feature sequence extracted by the first initial model is similar to the target label carried by the second sample behavior data sequence itself; in other words, the distribution of the sample behavior data in the second sample behavior data sequence predicted based on the first sample feature sequence should be close to the real distribution of the sample behavior data in the second sample behavior data sequence. Therefore, the third loss value can be determined based on the difference between the first prediction label and the target label corresponding to the second sample behavior data sequence.
[0047] Step S143: determining the second prediction label corresponding to the first sample behavior data sequence based on the second sample feature sequence.
[0048] Step S144: determining the fourth loss value based on the difference between the second prediction label and the target label corresponding to the first sample behavior data sequence.
[0049] Similarly, the label prediction model can also be used to predict the distribution of the sample behavior data in the first sample behavior data sequence based on the second sample feature sequence, and compare the predicted distribution with the actual distribution of the sample behavior data in the first sample behavior data sequence. If the predicted distribution is similar to the actual distribution, it also indicates that the feature extraction capability of the first initial model is good. That is, the fourth loss value is determined based on the difference between the second predicted label and the target label corresponding to the first sample behavior data sequence.
[0050] Specifically, the third loss value and the fourth loss value can be calculated by the following cross-entropy loss function:
[0051]
[0052] wherein p i is the self-supervised label of the ith app, q i is the frequency ratio of the ith APP predicted by the model, and V is the total number of APPs in the APP library.
[0053] In this embodiment, the distribution difference measurement algorithm based on Kullback-Leibler divergence (KL) divergence is used. The measurement methods such as MMD and DAD are also applicable, and will not be described here.
[0054] Step S145: The third loss value and the fourth loss value are weighted and summed to obtain the second loss value.
[0055] Further, the third loss value and the fourth loss value can be weighted and summed based on a pre-set weight coefficient to obtain the second loss value. The weight coefficient can be set according to the importance of the third loss value and the fourth loss value in actual demand, wherein the weight value is a value greater than 0 and less than 1, and the weight value is positively correlated with the importance. It can be seen that the difference between the distribution of the sample behavior data in the predicted adjacent behavior data sequence is used as the second loss value of the generative self-supervised learning, which can improve the ability of the first initial model to capture fine-grained information in the behavior data sequence.
[0056] Step S150: Based on the first loss value and the second loss value, the first initial model is iteratively trained until the first target condition is met, and the trained first initial model is obtained as a feature extraction model.
[0057] In some embodiments, referring to Figure 4 , step S150 can include the contents in steps S151 to S153:
[0058] Step S151: obtaining a first preset weight corresponding to the first loss value and a second preset weight corresponding to the second loss value.
[0059] Step S152: based on the first preset weight and the second preset weight, the first loss value and the second loss value are weighted and summed to obtain a total loss value.
[0060] Further, after obtaining the first loss value and the second loss value, the first preset weight corresponding to the first loss and the second preset weight corresponding to the second loss value can be further obtained, wherein the first preset weight and the second preset weight can be the weight values set by the user according to experience during model training. Obviously, the weight values of the first preset weight and the second preset weight can also be adjusted according to the importance of the first loss value and the second loss value in actual application, and the weight values are positively correlated with the importance. That is, the weight values of the first preset weight and the second preset weight can be adjusted according to the demand for modeling event level fine-grained information or the demand for modeling sequence level information in actual application, and the weight values are positively correlated with the demand.
[0061] Step S153: based on the total loss value, the first initial model is iteratively trained until the first target condition is met, and the trained first initial model is obtained as the feature extraction model.
[0062] In the embodiment, the total loss value obtained by step S150 is based on a pair of sample behavior data sequences. Further, after obtaining the total loss value corresponding to each pair of sample behavior data sequences in the current training batch, a total average loss value can be obtained, and then based on the total average loss value, the first initial model is iteratively trained until the first target condition is met, and the trained first initial model is obtained as the feature extraction model.
[0063] Optionally, the total average loss value can be calculated by the following formula:
[0064]
[0065] wherein N is the number of pairs of sample behavior data sequences in the current training batch, which can also be understood as the number of samples in the current training batch. In this way, the number of iterations is less and the training time is shorter, avoiding the problem of updating the model parameters once for each pair of sample behavior data sequences when training the first initial model directly, which leads to long model training time, large computer memory occupation, and more computer resources consumption.
[0066] Optionally, the aforementioned first target condition can be that the total average loss value is less than a preset value, the total average loss value no longer changes, or the number of training times reaches a preset number, etc. It can be understood that after iterative training of multiple training periods, each training period includes multiple iterative training, the model parameters of the first initial model are continuously optimized, so that the total average loss value becomes smaller and smaller, and finally becomes a fixed value or is less than the above preset value. At this time, it indicates that the first initial model after optimizing the model parameters has converged; of course, it can also be determined that the first initial model after optimizing the model parameters has converged after the number of training times reaches the preset number. At this time, the converged first initial model can be used as the feature extraction model. The preset value and the preset number are both preset, and their values can be adjusted according to different application scenarios. The present embodiment does not limit this.
[0067] In some embodiments, the first initial model can include an encoding module and a sequence feature extraction network, wherein the sequence feature extraction network can be a network structure constructed based on a self-attention mechanism.
[0068] In some embodiments, after step S150, a target behavior data sequence in a third period can be obtained; the target behavior data sequence is input into the feature extraction model to obtain a target feature sequence corresponding to the target behavior data sequence. The length of the third period is equal to the length of the first period and the second period, so that the length of the sequence input into the feature extraction model in the actual application of the feature extraction model is the same as the length of the training sample sequence, thereby ensuring the feature extraction capability of the feature extraction model. The target behavior data sequence can be extracted for a target user who needs to be profiled, for example, obtaining a target behavior data sequence generated by the target user operating a terminal device from October 1, 2022 to October 31, 2022. Further, the target behavior data sequence is input into the trained feature extraction model, so that the target feature sequence corresponding to the target behavior data sequence can be better extracted from the event-level fine-grained information and the sequence-level information. Therefore, the modeling of the user portrait of the target user based on the target feature sequence is more accurate, and the device manufacturer of the terminal device can provide more appropriate personalized services for the user based on the user portrait established based on the target feature sequence, thereby optimizing the user experience; of course, the advertiser can also predict the user's device browsing habits based on the target feature sequence, and more accurately push advertising information, thereby improving the efficiency of advertising push under the condition of limited advertising cost, etc.
[0069] In this embodiment, the distribution of events in the adjacent behavior data sequence is used as the objective function of generative self-supervised learning, and the adjacent sequence contrast learning is used as the self-supervised signal to train the feature extraction model. In this way, the data input based on the adjacent sequence naturally meets the combination requirement, effectively reducing the sample processing complexity; the feature extraction model trained in this way combines the ability of generative self-supervised learning to model event-level fine-grained information and the ability of contrastive task to model sequence-level information; at the same time, the cross-prediction of adjacent sequences improves the robustness and generalization ability of sequence representation, and the self-supervised learning based on distribution prediction effectively improves the ability to extract statistical information and co-occurrence information of event sequences, and alleviates the influence of random events.
[0070] Please refer to Figure 5 , Figure 5 The flowchart of a model training method provided by another embodiment of the present application is shown. The model training method provided by the embodiment of the present application will be described in detail below. The model training method can include the following steps: Figure 5
[0071] Step S210: Obtain a sample behavior data set in a plurality of target periods, each of the sample behavior data sets in the target periods including a plurality of sample behavior data.
[0072] Step S220: Sort each sample behavior data in each target period based on the generation time of the sample behavior data to obtain a sample behavior data sequence corresponding to each target period.
[0073] In this embodiment, the sample behavior data sets of different users in the same plurality of target periods can obtain the sample behavior data sets of each user in the plurality of target periods. The length of the target period is the same as the length of the first period and the second period mentioned in the foregoing embodiments. The plurality of target periods can be consecutive periods. Further, after obtaining the behavior sample data set, each behavior sample data in each behavior sample data set can be sorted according to the generation time of the behavior sample data to obtain a sample behavior data sequence corresponding to each target period. The order of sorting is generally from early to late according to time. Taking the sample behavior data set as an example, the operation behavior data set of the APP, the generation time of each behavior sample data can be understood as the start time of the APP.
[0074] In actual application, considering that the sample behavior data set may be contaminated to a certain extent during the mobile process, it is necessary to perform data preprocessing on the sample behavior data sequence in each target period of each target user, that is, to perform cleaning operation on the sample behavior data sequence.
[0075] Optionally, the number of sample behavior data in each sample behavior data sequence in the target period and the time information of the sample behavior data can be checked, and if the numbers are not equal, the sample behavior data sequence with shorter length can be filled. For example, if the number of APPs and the number of time stamps / lengths in a sample behavior data sequence are checked, if the numbers are not equal, the shorter one can be filled, such as using the APP with the most start times in the window range to fill when the number of APPs is too small, or directly deleting the sample. In this way, the length of each sample behavior data sequence can be ensured to be consistent.
[0076] Optionally, the coverage and generation frequency of each sample behavior in each sample behavior data sequence can also be counted. The sample behavior with low coverage / generation frequency cannot be fully trained in the model training process and will seriously expand the training parameters to affect the training efficiency. Therefore, the sample behavior data with low coverage / generation frequency below a certain threshold will be replaced by a preset sample behavior data. For example, the coverage and usage frequency of different APPs in the sample behavior data sequence are obtained, and the APP with low coverage / usage frequency cannot be fully trained in the model training process and will seriously expand the training parameters to affect the training efficiency. Therefore, all APPs below a certain threshold are replaced by a virtual APP. In this way, the effect and efficiency of model training can be ensured.
[0077] Optionally, two same sample behavior data with adjacent generation time close to each other in the sample behavior data sequence are merged, and the merged generation time uses the earliest generation time of the two, and the duration uses the sum of the durations of the two. For example, the same APP with adjacent start time close to each other in the sample behavior data sequence is merged, and the merged start time uses the earliest start time of the two, and the duration uses the sum of the durations of the two.
[0078] Optionally, if the generation time of the specified sample behavior data in the sample behavior data sequence is adjacent to the end time of the previous sample behavior data, and the end time of the specified sample behavior data is adjacent to the generation time of the subsequent sample behavior data, the type of the previous sample behavior data and the subsequent sample behavior data is the same, that is, the time interval between the previous sample behavior data and the subsequent sample behavior data is less than the preset time length; at this time, the specified sample behavior data is removed, and the previous sample behavior data and the subsequent sample behavior data are merged. For specific merging methods, please refer to the foregoing description. For example, if there are three adjacent sample behavior data APP1, APP2 and APP1 in the sample behavior data sequence, the start time of APP2 immediately follows the end time of the first APP1, and the end time of APP2 immediately follows the start time of the second APP1. When the start interval of the previous and subsequent APP1 is less than the preset time length, APP2 is directly removed, and the previous and subsequent APP1 are merged. As can be seen, APP2 is most likely to be an APP entered by user misoperation, for example, the start interface of APP1 contains the advertisement interface of APP2. If the user misclicks the start interface, APP2 will be jumped from APP1, and further, the user will immediately switch back to the APP1 actually wanted to use. Therefore, removing the sample behavior data corresponding to APP2 can reduce the learning of user misoperation behavior by the model, and affect the final feature extraction effect of the model.
[0079] Step S230: determining the target label corresponding to each sample behavior data sequence of each target period based on the distribution of each sample behavior data in the sample behavior data sequence corresponding to each target period.
[0080] In some embodiments, referring to Figure 6 , step S230 can include the contents of steps S231 to S233:
[0081] Step S231: for each sample behavior data sequence corresponding to each target period, obtaining the frequency of generation of each sample behavior data and the total frequency of generation of the plurality of sample behavior data.
[0082] Step S232: for each sample behavior data sequence corresponding to each target period, obtaining the ratio of the frequency corresponding to each sample behavior data to the total frequency, to obtain the first frequency corresponding to each sample behavior data.
[0083] In this mode, for each sample behavior data sequence corresponding to each target period, the frequency of each sample behavior data and the total frequency of all sample behavior data can be counted, wherein the total frequency is the sum of the frequency of each sample behavior data, which can be calculated by the following summation formula:
[0084]
[0085] Wherein, K represents the number of sample behavior data in the sample behavior data sequence, C i represents the frequency of the i-th sample behavior data, and C represents the total frequency.
[0086] Further, by calculating the ratio of the frequency of each sample behavior data to the total frequency, the first frequency corresponding to each sample behavior data can be obtained, that is, the probability distribution of all sample behavior data in each target period is obtained.
[0087] Step S233: For each sample behavior data sequence corresponding to each target period, based on the first frequency corresponding to each sample behavior data, the target label corresponding to each sample behavior data sequence corresponding to each target period is generated.
[0088] In some embodiments, the first frequency corresponding to each sample behavior data in each target period can be directly determined to obtain the probability distribution of the target period, and the probability distribution can be directly used as the target label corresponding to each sample behavior data sequence corresponding to each target period.
[0089] In another embodiment, please refer to Figure 7 , step S233 can include the contents of step S2331 to step S2334:
[0090] Step S2331: Obtain the number of users associated with each sample behavior data, and obtain the number of users corresponding to each sample behavior data.
[0091] Step S2332: Determine the importance of each sample behavior data based on the number of users corresponding to each sample behavior data and the total number of users.
[0092] In this way, after obtaining the probability distribution of the sample behavior data in each target period, the event distribution is reweighted according to importance considering that different events provide different amounts of information, and the obtained sequence list highlights the information of important events. Therefore, the number of sample users associated with each sample behavior data can be further obtained, the number of users corresponding to each sample behavior data is obtained, and then the importance of each sample behavior data is evaluated according to the total number of users and the number of users corresponding to each sample behavior data. It can be understood that the more the number of sample users associated with a certain sample behavior data, the poorer the ability to distinguish users based on the sample behavior data, that is, the category distinguishing ability, which is not suitable for classification. Therefore, the importance is negatively correlated with the number of users.
[0093] Optionally, the importance of each sample behavior data can be quantified based on the ratio of the number of users to the total number of users. The larger the ratio, the lower the importance.
[0094] Optionally, the importance of each sample behavior data can also be quantified by the formula log(P / P i +1), where P i represents the number of users corresponding to the ith behavior sample data, and P represents the total number of users.
[0095] Step S2333: determining the second frequency corresponding to each sample behavior data based on the importance of each sample behavior data and the first frequency corresponding to each sample behavior data.
[0096] Further, after obtaining the importance of each sample behavior data, the product of the importance of each sample behavior data and the first frequency corresponding to each sample behavior data can be obtained as the third frequency.
[0097] Specifically, the third frequency can be calculated by the following formula:
[0098]
[0099] wherein, r i is used to represent the first frequency corresponding to the ith behavior sample data, is used to represent the third frequency corresponding to the ith behavior sample data.
[0100] Further, the frequency and value of the third frequency of all sample behavior data in each target period are obtained as a target total frequency; finally, the ratio of the third frequency corresponding to each sample behavior data to the target total frequency is obtained to obtain the second frequency corresponding to each sample behavior data. In other words, the third frequency of each sample behavior data of the user is re-normalized to obtain the second frequency corresponding to each sample behavior data.
[0101] Optionally, normalization processing can be performed by the following normalization formula:
[0102]
[0103] wherein, the third frequency of the i-th sample behavior data, the second frequency for the i-th sample behavior data.
[0104] Step S2334: based on the second frequency corresponding to each sample behavior data, the target label corresponding to the sample behavior data sequence of each target period is generated.
[0105] It can be seen that the second frequency corresponding to each sample behavior data is a probability distribution determined based on importance reweighting, and the probability distribution in each target period is determined based on the second frequency corresponding to each sample behavior data, which can better reflect the distribution of sample behavior data in the sample behavior data sequence that plays a major role; and further, the target label generated based on the second frequency corresponding to each sample behavior data is more helpful to extract event feature information in the sample behavior data sequence that plays a major role.
[0106] Step S240: for each sample behavior data sequence corresponding to each target period, the target label corresponding to the sample behavior data sequence of each target period is added to obtain the training sample set.
[0107] In some embodiments, before adding the target label corresponding to each sample behavior data sequence, it can also be detected whether the sequence length of each sample behavior data sequence is greater than a preset length, and if greater than the preset length, the sample behavior data sequence greater than the preset length is truncated, and then the target label corresponding to the truncated sample behavior data sequence is added. In this way, the length of the sample behavior data sequence is prevented from exceeding the maximum input length of the first initial model.
[0108] Step S250: input each pair of sample behavior data sequences into the first initial model to obtain the first sample feature sequence corresponding to the first sample behavior data sequence and the second sample feature sequence corresponding to the second sample behavior data sequence.
[0109] Step S260: determining a first loss value based on the similarity between the first sample feature sequence and the second sample feature sequence.
[0110] Step S270: determining a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent a difference degree between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and a difference degree between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence.
[0111] Step S280: performing iterative training on the first initial model based on the first loss value and the second loss value until a first target condition is met, to obtain a trained first initial model as a feature extraction model.
[0112] In the embodiment, the specific implementation of steps S240 to S280 can refer to the content in the foregoing embodiments, which will not be described here again.
[0113] In the embodiment, when constructing the sample behavior data sequence in the training sample set, the event distribution is reweighted according to importance in view of the different information provided by different events, that is, the distribution prediction is reweighted and normalized based on importance, so that the distribution represented by the obtained target label can help to extract the event information playing a major role in the sequence, and further improve the feature extraction model obtained by training to extract the feature sequence playing a major role in the behavior data sequence.
[0114] Please refer to Figure 8 , Figure 8 A network structure schematic diagram of a model training method provided in the embodiment of the present application. The model training method provided in the embodiment of the present application will be described in detail below. Figure 8 The model training method provided in the embodiment of the present application will be described in detail below.
[0115] In the embodiment, the aforementioned first initial model mainly includes an encoding module and a sequence feature extraction network, and the iterative training on the first initial model is mainly to iteratively update the parameters in the encoding module and the sequence feature extraction network. The sequence feature extraction network can be a network structure mainly based on a self-attention mechanism, and can also be any time sequence network taking sequence as input, including but not limited to a long short-term memory (LSTM) network, a GRU network or a one-dimensional convolution network obtained by modifying the LSTM network.
[0116] Specifically, the encoding module can embed the corresponding sample behaviors and data in the first sample behavior data sequence and the second sample behavior data sequence into a vector sequence based on an Embedding technique The obtained d-dimensional dense vector, and the floating-point type context information such as the time length can be considered in the following three ways: discretizing the floating-point number, and encoding the floating-point value as a corresponding d-dimensional vector; or encoding the context information represented by the floating-point value as a unified d-dimensional vector, and multiplying the floating-point value and the d-dimensional vector to obtain the final encoding; or normalizing the floating-point value and retaining the scalar value.
[0117] Further, as shown in the following formula, after obtaining the encoding of the different context information of the event, the encodings are spliced to obtain a one-dimensional fusion vector, which is input into a fully connected layer to obtain a d-dimensional dense vector representing the event. Figure 9 Then, if the event sequence in the sub-window is empty, a fixed ID is assigned to the category context information of the virtual event, and the floating-point type information is assigned a value of 0.
[0118] In some embodiments, taking a sequence representation extraction network that is a self-attention mechanism network as an example, the d-dimensional dense vector obtained by the encoding module is input into the self-attention network, and the self-attention module calculates three vectors Q i ∈R d , i K i and V i for the i-th position of the sequence, and obtains the normalized weight coefficient a i of the j-th position to the i-th position by using the inner product of Q j and K ji , and uses a ji V j as the contribution of the j-th position to the i-th position, and the output of the i-th position is the sum of the contributions of all positions to the i-th position, that is, The module performs similar operations on each position to obtain an output sequence corresponding to the input sequence. Specifically, the following operations can be included:
[0119] First, according to the input event representation vector sequence X∈R T×d and the learnable network parameters W q ∈R d×d , W k ∈R d ×d , W v ∈R d×d , Q=XW q , K=XW k , and V=XWv ;
[0120] Secondly, Q, K, V are divided into N h The hth head
[0121]
[0122]
[0123]
[0124]
[0125] Then, the calculation results of each head are combined, where W o ∈R d×d Learnable parameters:
[0126] MultiHead(X)=Concat(head1,....,head Nh W o
[0127] And, define FFN computation, where W1∈R d×d ,b1∈R d ,W2∈R d×d b2∈R d Learnable parameters:
[0128] FFN(x) = max(0, xW1+b)W2+b2
[0129] The output O is obtained through layer normalization and residual calculation:
[0130] H'=LayerNorm(MulitHead(X)+X)
[0131] O = FFN(H') + H'
[0132] Finally, the output sequence is aggregated (e.g., maximum, minimum, average) to obtain a vector representation of the sequence, such as... Figure 6 O0 represents the first sample feature sequence extracted from the first sample behavior data sequence, and O1 represents the second sample feature sequence extracted from the second sample behavior data sequence. Then, based on the similarity between the first and second sample feature sequences, a first loss value is determined; where the first loss value is... Figure 6the alignment loss in the first loss value. The second loss value is determined based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, and represents a difference between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and a difference between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence. The second loss value is Figure 6 the APP distribution loss in the first loss value. Based on the first loss value and the second loss value, the network parameters W q , W k , and W v in the encoding module of the first initial model and the sequence representation extraction network are iteratively updated until a first target condition is met, and the first initial model after training is obtained as the feature extraction model. The first target condition can refer to the content in the foregoing embodiments, which will not be repeated here.
[0133] In this embodiment, the event distribution in the predicted adjacent behavior data sequence is used as the objective function of the generative self-supervised learning, and the adjacent sequence contrast learning is used as the self-supervised signal to train the feature extraction model. In this way, the data input based on the adjacent sequences naturally meets the combination requirement, effectively alleviating the sample processing complexity; the feature extraction model obtained by training combines the ability of the generative self-supervised learning to model the event-level fine-grained information and the ability of the contrast task to model the sequence-level information; at the same time, the adjacent sequence cross-prediction improves the robustness and generalization ability of the sequence representation, and the self-supervised learning based on the distribution prediction effectively improves the ability to extract the statistical information and co-occurrence information of the event sequence, and alleviates the influence of random events.
[0134] Please refer to Figure 10 , which shows a structural block diagram of a model training device 300 provided by an embodiment of the present application. The device 300 can include a training sample acquisition module 310, a feature sequence extraction module 320, a first loss value determination module 330, a second loss value determination module 340, and a model training module 350.
[0135] The training sample acquisition module 310 is configured to acquire a training sample set, the training sample set including a plurality of pairs of sample behavior data sequences, each pair of sample behavior data sequences including a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, and each pair of sample behavior data sequences being provided with a target label, the target label being used to represent a distribution of sample behavior data in the sample behavior data sequence.
[0136] The feature sequence extraction module 320 is configured to input each pair of sample behavior data sequences into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence.
[0137] The first loss value determination module 330 is configured to determine a first loss value based on a similarity between the first sample feature sequence and the second sample feature sequence.
[0138] The second loss value determination module 340 is configured to determine a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent a difference degree between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and a difference degree between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence.
[0139] The model training module 350 is configured to iteratively train the first initial model based on the first loss value and the second loss value until a first target condition is met, to obtain the trained first initial model as a feature extraction model.
[0140] In some embodiments, the second loss value determination module 340 can include a first label determination unit, a third loss value determination unit, a second label determination unit, a fourth loss value determination unit, and a second loss value determination unit. The first label determination unit can be configured to determine the first predicted label corresponding to the second sample behavior data sequence based on the first sample feature sequence. The third loss value determination unit can be configured to determine the third loss value based on the difference between the first predicted label and the target label corresponding to the second sample behavior data sequence. The second label determination unit can be configured to determine the second predicted label corresponding to the first sample behavior data sequence based on the second sample feature sequence. The fourth loss value determination unit can be configured to determine the fourth loss value based on the difference between the second predicted label and the target label corresponding to the first sample behavior data sequence. The second loss value determination unit can be configured to sum the third loss value and the fourth loss value to obtain the second loss value.
[0141] In some embodiments, the model training module 350 can include a weight acquisition unit, a total loss value determination unit, and an iterative training unit. The weight acquisition unit can be configured to acquire a first preset weight corresponding to the first loss value and a second preset weight corresponding to the second loss value. The total loss value determination unit can be configured to sum the first loss value and the second loss value based on the first preset weight and the second preset weight to obtain a total loss value. The iterative training unit can be configured to iteratively train the first initial model based on the total loss value until the first target condition is met, and obtain the trained first initial model as the feature extraction model.
[0142] In some embodiments, the training sample acquisition module 310 can include a sample behavior data acquisition unit, a sorting unit, a target label determination unit, and a sample set generation unit. The sample behavior data acquisition unit can be configured to acquire a sample behavior data set in a plurality of target periods, each of the sample behavior data sets including a plurality of sample behavior data. The sorting unit can be configured to sort each of the sample behavior data in each of the target periods based on the generation time to obtain a sample behavior data sequence corresponding to each of the target periods. The target label determination unit can be configured to determine the target label corresponding to the sample behavior data sequence of each of the target periods based on the distribution of each of the sample behavior data in the sample behavior data sequence of each of the target periods. The sample set generation unit can be configured to add the target label corresponding to each of the target periods to the sample behavior data sequence corresponding to each of the target periods to obtain the training sample set.
[0143] In this mode, the target label determination unit can include: a frequency acquisition subunit, a frequency acquisition subunit, and a target label generation subunit. Wherein the frequency acquisition subunit can be used to obtain the frequency of each sample behavior data and the total frequency of a plurality of sample behavior data for each sample behavior data sequence corresponding to the target period. The frequency acquisition subunit can be used to obtain the ratio of the frequency corresponding to each sample behavior data to the total frequency, and obtain the first frequency corresponding to each sample behavior data for each sample behavior data sequence corresponding to the target period. The target label generation subunit can be used to generate the target label corresponding to each sample behavior data sequence corresponding to the target period based on the first frequency corresponding to each sample behavior data for each sample behavior data sequence corresponding to the target period.
[0144] In this mode, the target label generation subunit can be specifically used to: obtain the number of users associated with each sample behavior data, to obtain the number of users corresponding to each sample behavior data; determine the importance degree corresponding to each sample behavior data based on the number of users corresponding to each sample behavior data and the total number of users; determine the second frequency corresponding to each sample behavior data based on the importance degree corresponding to each sample behavior data and the first frequency corresponding to each sample behavior data; and generate the target label corresponding to each sample behavior data sequence corresponding to the target period based on the second frequency corresponding to each sample behavior data.
[0145] In some embodiments, the model training apparatus 300 can further include: a target data sequence acquisition module and a feature extraction module. Wherein the target data sequence acquisition module can be used to obtain the target data sequence in the third period after the first initial model is iteratively trained based on the first loss value and the second loss value until the first target condition is met, and the first initial model after training is used as a feature extraction model. The feature extraction module can be used to input the target data sequence into the feature extraction model to obtain the target feature sequence corresponding to the target data sequence.
[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and module can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0147] In several embodiments provided in the present application, the coupling between the modules can be electrical, mechanical or other forms of coupling.
[0148] In addition, each function module in each embodiment of the present application can be integrated in one processing module, or each module can exist physically independently, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module.
[0149] In summary, the event distribution in the adjacent behavior data sequence is used as the objective function of generative self-supervised learning, and the adjacent sequence contrast learning is used as the self-supervised signal to train the feature extraction model. In this way, the data input based on the adjacent sequence naturally meets the combination requirement, effectively alleviating the sample processing complexity; the feature extraction model trained in this way combines the ability of generative self-supervised learning to model event-level fine-grained information and the ability of contrastive task to model sequence-level information; at the same time, the cross-prediction of adjacent sequences improves the robustness and generalization ability of sequence representation, and the self-supervised learning based on distribution prediction effectively improves the ability to extract statistical information and co-occurrence information of event sequences, and alleviates the influence of random events.
[0150] The above-described method provided by the embodiments of the present application can be executed by the computer device 400. The computer device can be an electronic terminal with data processing function, including but not limited to a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, an e-book reader, an MP3 player, an MP4 player, and a smart home device, etc. Of course, the computer device can also be a server, which can be a physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, network acceleration service (CDN), and basic cloud computing services such as big data and artificial intelligence platform. Figure 11 A computer device provided by the present application is described.
[0151] Referring to Figure 11 , Figure 11 A structural block diagram of a computer device 400 provided by an embodiment of the present application is shown, and the above-described method provided by the embodiments of the present application can be executed by the computer device 400. The computer device can be an electronic terminal with data processing function, including but not limited to a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, an e-book reader, an MP3 player, an MP4 player, and a smart home device, etc. Of course, the computer device can also be a server, which can be a physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, network acceleration service (CDN), and basic cloud computing services such as big data and artificial intelligence platform.
[0152] The computer device 400 in the embodiments of the present application can include one or more of the following components: a processor 401, a memory 402, and one or more application programs, wherein the one or more application programs can be stored in the memory 402 and configured to be executed by the one or more processors 401, and the one or more programs are configured to execute the method as described in the foregoing method embodiments.
[0153] The processor 401 can include one or more processing cores. The processor 401 connects various parts within the entire computer device 400 through various interfaces and lines, and performs various functions of the computer device 400 and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 402, and calling data stored in the memory 402. Optionally, the processor 401 can be implemented in at least one of a hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 401 can integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU is mainly used to process the operating system, user interface and application programs, etc.; the GPU is used to be responsible for the rendering and drawing of the display content; and the modem is used to process wireless communication. It can be understood that the above-mentioned modem can also be integrated into the processor 401, and be realized separately by a communication chip.
[0154] The memory 402 can include a random access memory (RAM) and can also include a read-only memory (ROM). The memory 402 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 402 can include a program storage area and a data storage area, wherein the program storage area can store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing each of the following method embodiments, etc. The data storage area can also store data created by the computer device 400 in use (such as the various corresponding relationships described above) and the like.
[0155] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described devices and modules can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0156] In several embodiments provided in the present application, the coupling or direct coupling or communication connection between the modules shown or discussed can be indirect coupling or communication connection between some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0157] In addition, each functional module in the embodiments of the present application can be integrated in one processing module, or each module can be physically present alone, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module.
[0158] Please refer to Figure 12 which shows a structural block diagram of a computer readable storage medium provided by an embodiment of the present application. The computer readable medium 500 stores program codes, which can be called and executed by a processor to perform the methods described in the above method embodiments.
[0159] The computer readable storage medium 500 can be an electronic storage such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM. Alternatively, the computer readable storage medium 500 includes a non-transitory computer readable medium. The computer readable storage medium 500 has a storage space for program codes 510 for performing any method steps in the above methods. These program codes can be read from or written into one or more computer program products. The program codes 510 can be compressed in an appropriate form, for example.
[0160] In some embodiments, a computer program product or computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of an electronic device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the electronic device perform the steps in the above method embodiments.
[0161] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not drive the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A model training method, characterized in that, The method comprises: obtaining a training sample set, the training sample set comprising a plurality of pairs of sample behavior data sequences, each pair of sample behavior data sequences comprising a first sample behavior data sequence within a first period and a second sample behavior data sequence within a second period adjacent to the first period, each pair of sample behavior data sequences carrying a target label, the target label being used to represent the distribution of sample behavior data in the sample behavior data sequence, the first sample behavior data sequence comprising a sequence of events generated by a user operating a terminal device within the first period, and the second sample behavior data sequence comprising a sequence of events generated by the user operating the terminal device within the second period; inputting each pair of sample behavior data sequences into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence; determining a first loss value based on the similarity between the first sample feature sequence and the second sample feature sequence; determining a second loss value based on the first sample feature sequence, the second sample feature sequence, the target label corresponding to the first sample behavior data sequence, and the target label corresponding to the second sample behavior data sequence, the second loss value being used to represent the difference between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and the difference between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence; iteratively training the first initial model based on the first loss value and the second loss value until a first target condition is met, obtaining the trained first initial model as a feature extraction model.
2. The method of claim 1, wherein, The method comprises: determining the first predicted label corresponding to the second sample behavior data sequence based on the first sample feature sequence; determining a third loss value based on the difference between the first predicted label and the target label corresponding to the second sample behavior data sequence; determining the second predicted label corresponding to the first sample behavior data sequence based on the second sample feature sequence; determining a fourth loss value based on the difference between the second predicted label and the target label corresponding to the first sample behavior data sequence; weighting and summing the third loss value and the fourth loss value to obtain the second loss value.
3. The method of claim 1, wherein, The method comprises: iteratively training the first initial model based on the first loss value and the second loss value until a first target condition is met, obtaining the trained first initial model as a feature extraction model. obtaining a first preset weight corresponding to the first loss value and a second preset weight corresponding to the second loss value; performing weighted summation on the first loss value and the second loss value based on the first preset weight and the second preset weight to obtain a total loss value; performing iterative training on the first initial model based on the total loss value until the first target condition is met, to obtain the trained first initial model as the feature extraction model.
4. The method according to any one of claims 1 to 3, characterized in that, The obtaining of the training sample set comprises: obtaining sample behavior data sets in a plurality of target periods, each of the sample behavior data sets in the target periods comprising a plurality of sample behavior data; sorting each of the sample behavior data in each of the target periods based on the generation time to obtain a sample behavior data sequence corresponding to each of the target periods; determining the target label corresponding to the sample behavior data sequence corresponding to each of the target periods based on the distribution of each of the sample behavior data in the sample behavior data sequence corresponding to each of the target periods; for each of the sample behavior data sequence corresponding to each of the target periods, adding the target label corresponding to the sample behavior data sequence corresponding to each of the target periods to obtain the training sample set.
5. The method of claim 4, wherein, The determining of the target label corresponding to the sample behavior data sequence corresponding to each of the target periods based on the distribution of each of the sample behavior data in the sample behavior data sequence corresponding to each of the target periods comprises: for each of the sample behavior data sequence corresponding to each of the target periods, obtaining the frequency of generation of each of the sample behavior data and the total frequency of generation of the plurality of sample behavior data; for each of the sample behavior data sequence corresponding to each of the target periods, obtaining the ratio of the frequency corresponding to each of the sample behavior data to the total frequency to obtain a first frequency corresponding to each of the sample behavior data; for each of the sample behavior data sequence corresponding to each of the target periods, generating the target label corresponding to the sample behavior data sequence corresponding to each of the target periods based on the first frequency corresponding to each of the sample behavior data.
6. The method of claim 5, wherein, The generating of the target label corresponding to the sample behavior data sequence corresponding to each of the target periods based on the first frequency corresponding to each of the sample behavior data comprises: obtaining the number of sample users associated with each of the sample behavior data to obtain the number of users corresponding to each of the sample behavior data; determining the importance degree corresponding to each of the sample behavior data based on the number of users corresponding to each of the sample behavior data and the total number of users; determining a second frequency corresponding to each of the sample behavior data based on the importance degree corresponding to each of the sample behavior data and the first frequency corresponding to each of the sample behavior data; generating the target label corresponding to the sample behavior data sequence corresponding to each of the target periods based on the second frequency corresponding to each of the sample behavior data.
7. The method according to any one of claims 1 to 3, characterized in that, After the first initial model is iteratively trained based on the first loss value and the second loss value until a first target condition is met, the first initial model after training is obtained as a feature extraction model, and the method further includes: obtaining a target behavior data sequence in a third period; inputting the target behavior data sequence into the feature extraction model to obtain a target feature sequence corresponding to the target behavior data sequence.
8. A model training apparatus, comprising: The device includes: a training sample acquisition module configured to acquire a training sample set, the training sample set including a plurality of pairs of sample behavior data sequences, each pair of sample behavior data sequences including a first sample behavior data sequence in a first period and a second sample behavior data sequence in a second period adjacent to the first period, each pair of sample behavior data sequences carrying a target label, the target label being used to represent a distribution of sample behavior data in the sample behavior data sequence, the first sample behavior data sequence including a sequence of events generated by a user operating a terminal device in the first period, and the second sample behavior data sequence including a sequence of events generated by the user operating the terminal device in the second period; a feature sequence extraction module configured to input each pair of sample behavior data sequences into a first initial model to obtain a first sample feature sequence corresponding to the first sample behavior data sequence and a second sample feature sequence corresponding to the second sample behavior data sequence; a first loss value determination module configured to determine a first loss value based on a similarity between the first sample feature sequence and the second sample feature sequence; a second loss value determination module configured to determine a second loss value based on the first sample feature sequence, the second sample feature sequence, a target label corresponding to the first sample behavior data sequence, and a target label corresponding to the second sample behavior data sequence, the second loss value being used to represent a difference between a first predicted label predicted based on the first sample feature sequence and the target label corresponding to the second sample behavior data sequence, and a difference between a second predicted label predicted based on the second sample feature sequence and the target label corresponding to the first sample behavior data sequence; a model training module configured to iteratively train the first initial model based on the first loss value and the second loss value until a first target condition is met, to obtain the first initial model after training as a feature extraction model.
9. A computer device, comprising: includes: one or more processors; a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs being configured to perform the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores program code, which can be called and executed by a processor to perform the method of any one of claims 1-7.
Citation Information
Patent Citations
Feature extraction model training method and device, equipment, medium and program product
CN114580533A
Model training method and device, electronic equipment and storage medium
CN114722826A