Data model training and data processing method, device, equipment and storage medium
Through the vectorization processing and feature extraction of the data model, user preference characteristics are determined and the data model is trained, which solves the problems of high cost and waste of resources in processing massive user data, and achieves efficient sharing and accuracy of user preference data.
Patent Information
- Application Number
- CN202010334097.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-24
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2040-04-24
AI Technical Summary
When the existing technology processes massive user data, it is costly for each service and application to construct user data separately, and there is a waste of data processing and use. Moreover, different services and applications may be constructed separately based on the same or similar user data, resulting in a waste of resources.
By obtaining the user's historical behavioral data sequence, and using the data model to perform vectorization processing and feature extraction, the user preference characteristics are determined after the fusion process, the data model is trained based on these characteristics and differences, and the user preference data is output, so as to achieve better results in different services and Preset data to be processed is shared across applications.
It reduces the cost of data construction, avoids waste of data processing and use, improves the accuracy and commonality of user preference data, and is suitable for various scenarios that require services and applications based on user preferences.
Smart Images

Figure CN113554450B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a data model training method, a data processing method and device, an electronic device, and a computer storage medium. Background Art
[0002] With the advent of the big data era, more and more services and applications need to rely on big data, especially the support of big data related to users. For example, services and applications related to e-commerce, services and applications related to online education, and so on.
[0003] At present, such services and applications are all based on their specific needs, processing the corresponding massive user data to obtain the final data they need, forming an end-to-end data processing. In this way, on the one hand, it is costly for each service and application to build user data based on its own needs; on the other hand, different services and applications may be based on the same or similar user data, and the use of separate construction also causes waste of data processing and use. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a data model training and data processing solution to at least partially solve the above problems.
[0005] According to a first aspect of an embodiment of the present invention, there is provided a data processing method, comprising: obtaining a user's historical behavior data sequence; inputting the historical behavior data sequence into a data model, wherein the data model is used to determine user preference data of the user based on the historical behavior data; and determining target data from preset data to be processed based on the user preference data output by the data model.
[0006] According to a second aspect of an embodiment of the present invention, a data model training method is provided, comprising: obtaining a training input sequence comprising a first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization head sequence of a user; inputting the training input sequence into a data model for obtaining user preference information, vectorizing the training input sequence through the data model, and performing feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; determining a user preference feature of the user based on the data feature of the first historical behavior data sequence; and training the data model based on a first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence.
[0007] According to a third aspect of an embodiment of the present invention, a data processing method is provided, comprising: receiving a model training request sent by a client for requesting training of a preset data model; obtaining training data according to the model training request; and using the training data to train the data model through the data model training method described in the second aspect.
[0008] According to a fourth aspect of an embodiment of the present invention, a data model training device is provided, comprising: a first acquisition module, used to acquire a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization head sequence of a user; a first model processing module, used to input the training input sequence into a data model for acquiring user preference information, vectorize the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; a second model processing module, used to determine the user preference features of the user based on the data features of the first historical behavior data sequence; and a third model processing module, used to train the data model based on a first difference between the user preference features and the vector corresponding to the second historical behavior data sequence.
[0009] According to a fifth aspect of an embodiment of the present invention, a data processing device is provided, comprising: a second acquisition module for acquiring a user's historical behavior data sequence; an input module for inputting the historical behavior data sequence into a data model, wherein the data model is a data model obtained by training the device according to the third aspect; and a determination module for determining target data from preset data to be processed based on user preference data output by the data model.
[0010] According to the sixth aspect of an embodiment of the present invention, a data processing device is provided, comprising: a receiving module for receiving a model training request sent by a client, for requesting training of a preset data model; a third acquisition module for acquiring training data according to the model training request; and using the training data to train the data model through the device as described in the fourth aspect.
[0011] According to the seventh aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the data model training method described in the second aspect; or, to perform operations corresponding to the data processing method described in the first aspect or the third aspect.
[0012] According to an eighth aspect of an embodiment of the present invention, a computer storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the data model training method as described in the second aspect is implemented; or, the data processing method as described in the first aspect or the third aspect is implemented.
[0013] According to the data processing scheme of this embodiment, the data model is used to output the user preference data, and then the target data is determined from the data to be processed according to the user preference data, so as to realize the application of the user preference data to various scenarios that require subsequent services and applications based on user preferences. Among them, the preset data to be processed can be the demand data of different services or applications, so that the same user preferences can be used by different services or applications, and each service and application does not need to build dedicated user preference data that meets its own needs, which reduces the data construction cost and avoids the waste of data processing and use.
[0014] According to the data model training scheme provided by the embodiment of the present invention, the training input sequence of the input data model includes both the user's historical behavior data sequence and the preset characterization head sequence. After these sequences are input into the data model, the data features used to characterize the first historical behavior data sequence can be obtained through vectorization and subsequent feature extraction and fusion of the first historical behavior vector and the characterization head vector. Since the data features are based on the first historical behavior vector and the characterization head vector, the information contained in the first historical behavior data sequence is fully integrated. Since the historical behavior data can reflect the user's habits and preferences, the user's preference features can be obtained based on the data features. Then, according to the vector corresponding to the user preference feature and the second historical behavior data sequence, the difference between the two is determined, and the data model is trained based on the difference. Since the second historical behavior data sequence can also reflect the user's habits and preferences, and it can be actual user behavior data, the difference between the two can reflect the difference between the result obtained by the data model and the actual situation, and the data model training is carried out based on this benchmark, so as to make the user preferences obtained by the trained data model more consistent with the actual user preferences.
[0015] According to the solution of the embodiment of the present invention, the data model can be applied to various scenarios that require subsequent services and applications based on user preferences, and the same user preferences can be used by different services or applications. Each service and application does not need to build dedicated user data that meets its own needs, which reduces the cost of data construction and avoids waste in data processing and use. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0017] Figure 1A A flowchart of the steps of a data model training method according to Embodiment 1 of the present invention;
[0018] Figure 1B for Figure 1A A schematic diagram of an example of a training process in the illustrated embodiment;
[0019] Figure 2A is a structural block diagram of a data model according to the second embodiment of the present invention;
[0020] Figure 2B This is a schematic diagram of the structure of a data model according to the second embodiment of the present invention;
[0021] Figure 2C A flowchart of the steps of a data model training method according to Embodiment 2 of the present invention;
[0022] Figure 3A is a flowchart of a data processing method according to Embodiment 3 of the present invention;
[0023] Figure 3B for Figure 3A A schematic diagram of a usage scenario in the illustrated embodiment;
[0024] Figure 3C for Figure 3A A schematic diagram of a usage scenario in the illustrated embodiment;
[0025] Figure 3D for Figure 3A A schematic diagram of a usage scenario in the illustrated embodiment;
[0026] Figure 4A is a flowchart of a data processing method according to Embodiment 4 of the present invention;
[0027] Figure 4B for Figure 4A A schematic diagram of a usage scenario in the illustrated embodiment;
[0028] Figure 5 This is a structural block diagram of a data model training device according to Embodiment 5 of the present invention;
[0029] Figure 6 is a structural block diagram of a data processing device according to Embodiment 6 of the present invention;
[0030] Figure 7 is a structural block diagram of a data processing device according to Embodiment 7 of the present invention;
[0031] Figure 8 FIG. 4 is a schematic diagram of the structure of an electronic device according to Embodiment 8 of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0033] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0034] To facilitate understanding of the solution provided by the embodiment of the present invention, the following first describes the training process of the data model used in the embodiment of the present invention, and then describes the data processing solution provided by the embodiment of the present invention based on the trained data model.
[0035] Embodiment 1
[0036] Reference Figure 1A , shows a step flow chart of a data model training method according to embodiment 1 of the present invention.
[0037] The data model training method of this embodiment includes the following steps:
[0038] Step S102: Obtain a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation header sequence of the user.
[0039] The historical behavior data may be any appropriate data representing the user's past behavior, including but not limited to: purchasing behavior, browsing behavior, searching behavior, clicking behavior, watching or playing behavior, etc. The first historical behavior data sequence and the second historical behavior data sequence are usually data sequences representing the same behavior, such as both purchasing behavior or both searching behavior.
[0040] The data in the first historical behavior data sequence may be data with a certain time series relationship within a certain time period, or data within the time period but without a time series relationship. The time series relationship can better characterize the user's behavior pattern to provide more accurate information later. Similarly, the data in the second historical behavior data sequence may be data with a certain time series relationship within a certain time period, or data without a time series relationship within the time period. In one feasible manner, the first historical behavior data sequence and the second historical behavior data sequence may be two data sequences that are sequential in time and do not overlap in time, such as the time period corresponding to the first historical behavior data sequence is earlier than the time period corresponding to the second historical behavior data sequence, so as to provide different bases and references for the subsequent training of the data model.
[0041] The preset characterization header sequence corresponds to the subsequent user preference features, and can be considered as an initial data sequence representing the user preference. The initial data of the characterization header sequence can be appropriately set by a person skilled in the art according to actual needs, such as appropriately setting the number of data groups in the characterization header sequence, as long as each data group is different. For example, if it is necessary to characterize the user's preferences from 8 aspects, the data groups in the characterization header sequence can be set to 8 groups, etc. The embodiment of the present invention does not limit the number of data groups in the characterization header sequence, and the specific distinguishing data of each data group.
[0042] Step S104: Input the training input sequence into the data model used to obtain user preference information, vectorize the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence.
[0043] The data model has settings for vectorizing the training input sequence (such as the input vector layer), and for feature extraction and fusion of the vectors (such as the Transformer structure layer or the Bert structure layer, etc.). Through these settings, data features for characterizing the first historical behavior data sequence can be obtained. Because the data in the characterization header sequence may not have actual semantics, it will not have much impact on the semantic expression of the first historical behavior data sequence, so that the data features obtained after the above-mentioned settings mainly express the semantics of the first historical behavior data sequence. Based on this, the user preference features subsequently obtained and corresponding to the characterization header sequence are also mainly obtained through the semantics of the first historical behavior data sequence, which can more accurately express the user's preferences.
[0044] Step S106: Determine the user preference characteristics of the user according to the data characteristics of the first historical behavior data sequence.
[0045] After the aforementioned feature extraction and fusion processing, multiple data features corresponding to the representation head vector and the first historical behavior vector can be obtained. As mentioned above, these data features better express the semantics of the first historical behavior data sequence, and the user preference characteristics of the user can be determined based on the data features corresponding to the representation head vector.
[0046] Step S108: training the data model according to the first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence.
[0047] In an embodiment of the present invention, the second historical behavior data sequence represents the behavior information of the user in a certain period of time, and can be considered as the user's real behavior data. After being vectorized in the data model, it does not participate in feature extraction and fusion processing. After obtaining the user preference feature, the difference between the vector corresponding to the second historical behavior data sequence and the user preference feature can be obtained by appropriate means, such as the loss function method, thereby reflecting the gap between the user preference obtained by the data model and the user's actual preference. Then, the data model is trained on this basis until the training termination condition is met. Among them, the training termination condition may be that the number of training times reaches the set number of times, or that the difference is within the preset difference range, etc. In actual applications, the set number of times and the preset difference range can be appropriately set by those skilled in the art according to actual conditions, and the embodiment of the present invention does not limit this.
[0048] The following is a simple process example to illustrate the above process. Figure 1B shown.
[0049] Assume that user A browses products five times on the first day, and forms the first historical behavior data sequence according to the browsing order<a1、a2、a3、a4、a5> User A browses products three more times on the second day, forming the second historical behavior data sequence according to the browsing order<b1、b2、b3> Assuming that we want to obtain user preference data from three perspectives, the representation header sequence can be set as<x1、x2、x3> Based on the above sequence, generate the training input sequence of user A<x1、x2、x3、a1、a2、a3、a4、a5、b1、b2、b3> The training input sequence is input into the data model, and vectorization is first performed to obtain the corresponding vector<x1’、x2’、x3’、a1’、a2’、a3’、a4’、a5’、b1’、b2’、b3’> . For the<x1’、x2’、x3’、a1’、a2’、a3’、a4’、a5’> Perform feature extraction and fusion processing to generate data features for characterizing the first historical behavior data sequence<Hx1’、Hx2’、Hx3’、Ha1’、Ha2’、Ha3’、Ha4’、Ha5’> , each element in this data feature is a pair<x1’、x2’、x3’、a1’、a2’、a3’、a4’、a5’> The elements that have been semantically fused with all the elements in the , contain the information of each element in it.<Hx1’、Hx2’、Hx3’> and<x1、x2、x3> Corresponding, or, we can also say, with<x1’、x2’、x3’> Corresponding. According to<Hx1’、Hx2’、Hx3’> User preference features can be obtained<U1、U2、U3> , such as obtained by nonlinear transformation, etc. Calculation<U1、U2、U3> and<b1’、b2’、b3’> The data model is trained based on the difference, including but not limited to training various weights, training parameters, hyper parameters, etc. When the training reaches a set number of times, such as 1000 times, the training can be completed. However, it is not limited to this, and the difference can also be set to be less than a preset difference threshold, and then the training is completed.
[0050] After the data model training is completed, if the data of user B, such as browsing behavior data sequence<c1、c2、c3、c4、c5> , if there are three recommended products corresponding to the vector<d1、d2、d3> , then you can<c1、c2、c3、c4、c5> Input the trained data model, and then according to the preferences of user B output by the data model,<d1、d2、d3> Among the corresponding products, the products that match the preferences of user B are selected and recommended to user B.
[0051] Through this embodiment, the training input sequence of the input data model includes both the user's historical behavior data sequence and the preset characterization head sequence. After these sequences are input into the data model, through vectorization and subsequent feature extraction and fusion of the first historical behavior vector and the characterization head vector, the data feature used to characterize the first historical behavior data sequence can be obtained. Because the data feature is based on the first historical behavior vector and the characterization head vector, it fully integrates the information contained in the first historical behavior data sequence. Since the historical behavior data can reflect the user's habits and preferences, the user's preference feature can be obtained based on the data feature. Then, according to the vector corresponding to the user preference feature and the second historical behavior data sequence, the difference between the two is determined, and the data model is trained based on the difference. Since the second historical behavior data sequence can also reflect the user's habits and preferences, and it can be actual user behavior data, the difference between the two can reflect the difference between the result obtained by the data model and the actual situation, and the data model training is carried out based on this, so as to make the user preferences obtained by the trained data model more consistent with the actual user preferences.
[0052] According to the solution of this embodiment, the data model can be applied to various scenarios that require subsequent services and applications based on user preferences, and the same user preferences can be used by different services or applications. Each service and application does not need to build dedicated user data that meets its own needs, which reduces the cost of data construction and avoids waste in data processing and use.
[0053] The data model training method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, PCs, etc.
[0054] Embodiment 2
[0055] To facilitate the description of the data model training method provided in the embodiment of the present invention, taking a data model instance as an example, the structure of the data model used in the embodiment of the present invention is first described.
[0056] First, for the training input sequence input into the data model, in this embodiment, the first historical behavior data sequence includes multiple historical behavior data groups of the user in the first time period, each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes multiple historical behavior data groups of the user in the second time period, each historical behavior data group includes a behavior object element and a behavior time element; the representation header sequence includes multiple different representation data groups, each representation data group includes a representation element and a preset time element, the representation elements in the multiple representation data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element (including the behavior time element in the first historical behavior data sequence and the behavior time element in the second historical behavior data sequence). In this way, it can be clearly indicated when the user performed the behavior operation on what object, and the user's behavior can be explained from a time perspective, such as the user likes to browse book products during the day and likes to browse clothing products at night, etc.
[0057] Further optionally, the first time period is earlier than the second time period, and the preset time elements in the multiple characterization data groups are the same. Thus, the data in the second historical behavior data sequence corresponding to the second time period can be regarded as future behavior data based on the first historical behavior data sequence, which is more useful for reference, especially when the second historical behavior data is used as data for comparison with user preferences. Setting the preset time elements in multiple characterization data groups to the same element can simplify the data processing of the characterization header sequence by the data model and improve the training efficiency of the data model. However, it is not limited to this, the preset time elements in the characterization header sequence can also be different, which is also applicable to the solution of the embodiment of the present invention.
[0058] The training input sequence is input into the data model to train the data model. In this example, the data model includes: an input vector layer, a vector fusion layer, a feature extraction layer, and a processing layer, such as Figure 2A shown.
[0059] Among them, the input vector layer is used to convert each element in the training input sequence into a corresponding vector respectively; the vector fusion layer is used to merge the vectors corresponding to the elements corresponding to the first historical behavior data sequence after vectorization processing and the elements corresponding to the characterization header sequence, in units of data groups, and generate training vectors based on the merging results; the feature extraction layer is used to extract and fuse the training vectors, and output data features for characterizing the first historical behavior data sequence; the processing layer is used to determine the user preference features of the user based on the data features of the first historical behavior data sequence; determine the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence, and train the data model based on the first difference.
[0060] In order to enrich the functions of the data model, improve the efficiency of data utilization, and make the training effect of the data model better, in a feasible way, the vector fusion layer is also used to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence; mask the behavior object elements in the selected historical behavior data groups and obtain the corresponding mask vectors; the processing layer is also used to predict the behavior object of the mask vector according to the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model according to the first difference and the second difference. Among them, the feature extraction layer includes multiple layers, and the multiple feature extraction layers are all Transformer structure layers. Alternatively, the feature extraction layer can be a Bert4Rec structure layer.
[0061] A conventional Transformer network includes an encoding layer Encoder and a decoding layer Decoder. When implementing the feature extraction layer of the embodiment of the present invention, the structure of the encoding layer Encoder of the Transformer network can be adopted, which effectively extracts and fuses features through a multi-head self-attention mechanism (Multi-head Attention).
[0062] However, it is not limited to this. In another feasible solution, the feature extraction layer can also adopt the Bert4Rec structure. Bert4Rec is based on the Bert model. For an input vector such as [v1, v2, ..., vt-1], its output is a vector [h1, h2, ..., ht-1] containing context information. In addition, the Bert4Rec model can realize prediction. For example, when predicting the interactive item vt of the user at time t, the training method of the Masked Language Model in BERT can be used. By converting the input of the corresponding position into a [mask] mark and taking it together with the vectors corresponding to other interactive items as input, the prediction of vt can be realized. It not only effectively utilizes some functions of Bert, but also has a significant improvement in performance. Bert4Rec can also effectively extract and fuse features through a multi-head self-attention mechanism.
[0063] An example of a data model based on the above structure is as follows Figure 2B As shown, in this data model, the input vector layer is indicated as "Item & Time Embedding Layer", the vector fusion layer is indicated as "Masking & Time Fusion Layer", the feature extraction layer is indicated as "L Transformer Layer", and the processing layer in this example is above the feature extraction layer. In addition, Figure 2BIn the figure, “Input” is used to indicate the training input sequence input into the data model.
[0064] Based on the above structure, the data model training method of this embodiment is as follows: Figure 2C As shown, the following steps are included:
[0065] Step S202: Obtain a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation header sequence of the user.
[0066] In one feasible manner, a user data sequence for training may be obtained, wherein the user data sequence includes: a first historical behavior data sequence and a second historical behavior data sequence of the user, wherein the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times; a preset representation header sequence is added before the user data sequence to generate the training input sequence. In this embodiment, the behavior time of the first historical behavior data sequence is earlier than the behavior time of the second historical behavior data sequence.
[0067] In one example, the first historical behavior data sequence of user i is set to in, It represents the nth behavior data of user i in the time period [T-D1, T), which can be interactive behavior data such as purchase, browsing, and search. Indicates that user i is in t n Time and Behavior Objects n Therefore, the first time period corresponding to the first historical behavior data sequence is [T-D1, T). Its historical behavior data set, each historical behavior data set includes behavior object element j n and the behavior time element t n .
[0068] The second historical behavior data sequence of user i is: It is used to indicate the behavior data sequence of user i in the time period [T, T+D2), and b(i) is the number of interactions of user i in the time period. It can be seen that the second time period corresponding to the second historical behavior data sequence is [T, T+D2), Each element in is its historical behavior data set, and Similarly, each historical behavior data set includes behavior object element j n+m and the behavior time element t n+m . Among them, 1<=m<=b(i).
[0069] In addition, in this example, a characterization header sequence CLS is also preset, including <(CLS1, t0), (CLS2, t0), ..., (CLS C , t0)>, each parenthesis is a characterization data group, which includes characterization elements such as CLS1, CLS2, etc., and a preset time element, namely t0. The specific number of characterization data groups can be appropriately set by those skilled in the art according to actual needs, and is illustrated as C in this example. Moreover, in this example, the time indicated by t0 is earlier than time T-D1. Because the characterization header sequence is used to obtain corresponding user preference features after subsequent data model processing, the same characterization header sequence can be used even for different users. By setting the characterization header sequence, subsequent user preference features can be expressed in the form of a set of vectors, and each vector in the user preference features can express different meanings.
[0070] Furthermore, if Figure 2B As shown in the "Input" section, the representation header sequence is added before the user data sequence (i.e., the first historical behavior data sequence and the second historical behavior data sequence) to generate a training input sequence. In addition, since the second historical behavior data sequence is mainly used for subsequent comparison, its behavior time element can be omitted to reduce the processing burden of the data model and improve the training efficiency of the data model.
[0071] After the training input sequence is generated, it can be input into the data model for use in data model training.
[0072] Step S204: input the training input sequence into a data model for acquiring user preference information, and perform vectorization processing on the training input sequence through the data model.
[0073] In one feasible manner, each element in the training input sequence can be vectorized using the data model; and the elements corresponding to the first historical behavior data sequence after vectorization and the elements corresponding to the representation header sequence are merged in units of data groups; and corresponding training vectors are generated based on the merging results.
[0074] In such Figure 2B In the data model shown in , vectorization is performed through the "Item&Time Embedding Layer" layer. As shown in the figure, for the representation header sequence CLS, the function f cls (*) Vectorize the representation elements in CLS using function f t (*) Vectorize the preset time element. For the behavior object element in the first historical behavior data sequence and the behavior object element in the second historical behavior data sequence, use the function f j(*) is vectorized. For the behavior time element in the first historical behavior data sequence, the function f is also used t (*) It is subjected to vectorization processing. Among them, the function f used for vectorization processing is cls (*), f t (*) and f j (*) can be any appropriate function, which is not limited in the present embodiment. After vectorization, the relevant elements can be converted into d-dimensional vectors, such as Figure 2B The "CLS1", "CLS C ”, “V N ”, “V N+1 ”,"t0”,"t N "wait.
[0075] Then, the vectorized elements are merged in units of data groups, such as Figure 2B In the , "CLS1" and "t0" are combined into "eCLS1", "CLS C " and "t0" are combined into "eCLS C ”, “V1” and “t1” are merged into “e1”, “MASK” and “t2” are merged into “e2”, and so on. Then, according to the merging result, the corresponding training vector is generated, that is, the vector composed of the above merged vectors.
[0076] In addition, by Figure 2B As can be seen from the figure, in this example, before merging the vectorized elements in units of data groups, some historical behavior data groups are randomly selected from multiple historical behavior data groups in the first historical behavior data sequence; masking is performed on the behavior object elements in the selected historical behavior data groups, and the corresponding mask vector is obtained, such as Figure 2B In , after j2 is vectorized and V2 is obtained, it is masked and the corresponding mask vector is generated. Figure 2B In the figure, it is indicated as "MASK" so that the data model can also realize the behavior object prediction function. In a feasible way, the probability of randomly selecting part of the historical behavior data group is set to 15%, so as to realize the prediction of the behavior object at low cost and effectively.
[0077] Step S206: performing feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing, to obtain data features for characterizing the first historical behavior data sequence.
[0078] In one feasible manner, the first historical behavior vector and the representation head vector obtained after the vectorization process can be subjected to feature extraction and fusion processing through a multi-layer self-attention mechanism to obtain data features corresponding to each data group in the first historical behavior data sequence and data features corresponding to each data group in the representation head sequence. Whether it is a Transformer structure, a Bert structure, or a Bert4Rec structure, they all have a multi-layer self-attention mechanism, which uses the self-attention mechanism to take each vector as a benchmark, effectively fuse the semantic information of other vectors, and obtain an effective representation of the vector.
[0079] Figure 2B The Bert4Rec structure is adopted, that is, the L-layer Transformer structure (the encoding layer). The specific structure and implementation details of feature extraction and fusion can be referred to the relevant description in the relevant technology, which will not be repeated here. Figure 2B As can be seen from the figure, after the feature extraction and fusion processing of the “L Transformer Layer”, the data features used to characterize the first historical behavior data sequence can be obtained, including: the data features h corresponding to the characterization head vector CLS_1 ,……h CLS_C , and the data features h1,h2,…h corresponding to the first historical behavior vector N .
[0080] Step S208: Determine the user preference characteristics of the user according to the data characteristics of the first historical behavior data sequence.
[0081] The method comprises: determining the user preference feature of the user according to the data feature corresponding to each data group in the characterization header sequence.
[0082] like Figure 2B As shown in CLS_1 ,……h CLS_C , through the function f u (*) After processing, the user preference features U1…U C Among them, f u (*) is used for data feature h CLS_1 ,……h CLS_C A nonlinear transformation is performed. In a feasible manner, the nonlinear transformation can be implemented as a nonlinear transformation based on a GELU (Gaussian Error Linear Unit) to generate a d-dimensional user preference feature.
[0083] In addition, from Figure 2BIt can also be seen that for the mask vector MASK corresponding to j2, after feature extraction and fusion processing by "L TransformerLayer", the data feature h2 is obtained, and then, through the function f O (*) After nonlinear transformation, vector O2 is generated. u (*)Similar, f O (*) can also be implemented as a GELU-based nonlinear transformation to obtain the corresponding vector O2.
[0084] Step S210: training the data model according to the first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence.
[0085] In this embodiment, the first difference between the vector corresponding to the user preference feature and the second historical behavior data sequence is calculated through the preset NCE (Noise Contrastive Estimation) function; according to the first difference, the data model is trained. In order to reduce the complexity of loss calculation, reduce time consumption, and handle loss calculation based on a large amount of training input sequence data, in this embodiment, the loss function adopts the NCE function. The NCE function compares the "real sample" (positive sample, such as the vector corresponding to the second historical behavior data sequence) with the "noise sample" (negative sample, such as data collected from other users' historical behavior data) in order to discover the law of the "real sample". For example, the difference (loss value) between the user preference feature and the vector corresponding to the second historical behavior data sequence is calculated through NCE, and the difference (loss value) between the user preference feature and the vector corresponding to the negative sample data sequence (pre-set) of the "noise sample" is calculated, and then the data model is trained based on these differences.
[0086] Further optionally, the NCE function may be implemented as an InfoNCE (NCE for mutual information estimation) function to more effectively optimize the training of the data model, especially to optimize the training of the ENCODER part of the data model.
[0087] It should be noted that if the data model also has a prediction function, such as performing mask processing on a vector as mentioned above, when training the data model, the mask vector can also be predicted for a behavior object based on the result of the feature extraction and fusion processing, and the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector is determined. Based on this, training the data model may include: training the data model based on the first difference and the second difference.
[0088] like Figure 2BAs shown in, on the one hand, based on the user preference characteristics, the vector corresponding to the second historical behavior data sequence, and the vector corresponding to the negative sample pre-built in the data model, the first difference (shown in the figure as "Matching NCE LOSS") is calculated by the InfoNCE function; on the other hand, based on the prediction vector O2 obtained according to the mask vector and the vector V2 corresponding to the behavior object element corresponding to the mask vector, the second difference (shown in the figure as "MLM NCELOSS") is calculated by the InfoNCE function; and then, based on the first difference and the second difference, the data model is trained.
[0089] The training cycle of the data model is iterated until the training termination condition is met, for example, the set number of training times is reached.
[0090] The data model obtained through training in the above process can not only determine the user's preferences more accurately based on the user's historical behavior data, but also predict the user's possible future behavior based on the user's historical behavior data.
[0091] Through this embodiment, the training input sequence of the input data model includes both the user's historical behavior data sequence and the preset characterization head sequence. After these sequences are input into the data model, through vectorization and subsequent feature extraction and fusion of the first historical behavior vector and the characterization head vector, the data feature used to characterize the first historical behavior data sequence can be obtained. Because the data feature is based on the first historical behavior vector and the characterization head vector, it fully integrates the information contained in the first historical behavior data sequence. Since the historical behavior data can reflect the user's habits and preferences, the user's preference feature can be obtained based on the data feature. Then, according to the vector corresponding to the user preference feature and the second historical behavior data sequence, the difference between the two is determined, and the data model is trained based on the difference. Since the second historical behavior data sequence can also reflect the user's habits and preferences, and it can be actual user behavior data, the difference between the two can reflect the difference between the result obtained by the data model and the actual situation, and the data model training is carried out based on this, so as to make the user preferences obtained by the trained data model more consistent with the actual user preferences.
[0092] According to the solution of this embodiment, the data model can be applied to various scenarios that require subsequent services and applications based on user preferences, and the same user preferences can be used by different services or applications. Each service and application does not need to build dedicated user data that meets its own needs, which reduces the cost of data construction and avoids waste in data processing and use.
[0093] The data model training method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, PCs, etc.
[0094] Embodiment 3
[0095] Reference Figure 3A , shows a step flow chart of a data processing method according to embodiment 3 of the present invention.
[0096] This embodiment performs corresponding data processing based on the data model obtained by training in the above-mentioned embodiment 1 or 2. The data processing method of this embodiment includes the following steps:
[0097] Step S302: Obtain the user's historical behavior data sequence.
[0098] The historical behavior data sequence may be a historical purchase behavior data sequence, a historical browsing behavior data sequence, or a historical search behavior data sequence of the user.
[0099] Step S304: Input the historical behavior data sequence into the data model.
[0100] The data model is a data model trained according to the method in Embodiment 1 or 2. That is, in this embodiment, the historical behavior data of multiple users are used to train the data model before obtaining the historical behavior data sequence of the user. Based on this, the trained data model can be directly used in this step.
[0101] Step S306: Determine target data from preset data to be processed according to the user preference data output by the data model.
[0102] The data to be processed may be data of objects to be recommended.
[0103] For example, target data is determined based on the degree of association between user preference data output by the data model and data to be processed, such as object data to be recommended, such as selecting part of object data to be recommended from multiple object data to be recommended.
[0104] In one feasible manner, the degree of association between the user preference data and the data to be processed can be determined by a preset scoring function. The scoring function can be implemented as:
[0105] Formula 1:
[0106] Among them, the constraints π c|i,j represents the weight, represents the user preference characteristics of user i, v j represents the vector corresponding to the data to be processed, and α is a scalable hyperparameter greater than 0 so that s θ The score of (i, j) falls between [-α, α].
[0107] Assuming that a matching pair of a user vector (such as a user preference feature) and a target vector (such as a vector corresponding to the data to be processed) can be effectively obtained through an appropriate method such as a vector indexing engine, the above formula 1 can be simplified to formula 2, namely:
[0108]
[0109] In this case, α may optionally be 20.
[0110] Through the above scoring formula, the target data can be effectively determined from the data to be processed.
[0111] The following uses an e-commerce scenario as an example to illustrate the above process.
[0112] In e-commerce platforms, user preferences currently play an increasingly important role in scenarios such as recommendation, search, and prediction. However, when using traditional methods, it is usually costly for each scenario to build user preferences to serve itself. Through the embodiments of the present invention, the massive, structured data in the e-commerce platform can be used to build universal user preferences, thereby serving each scenario in a more lightweight manner.
[0113] In one example, if Figure 3B As shown in the figure, user A has five purchase behaviors within a certain period of time, such as within a week, which is represented as a historical behavior data sequence<a1、a2、a3、a4、a5> , input it into the trained data model to obtain the purchase preference data of user A, such as the purchase preference characteristics of user A<U1、U2、U3> . Suppose, there are ten items to be recommended, represented as a product sequence<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> , then we can calculate<U1、U2、U3> and<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> The degree of association (also known as the degree of matching) of each product in the list is set to obtain 10 association probabilities with the ten products to be recommended. The recommended order of the ten products to be recommended is determined from large to small according to the probability value.<b4、b5、b6、b7、b1、b2、b3、b8、b9、b10> , then ten items can be recommended to user A in this order, or, alternatively, the top three items can be selected as recommended items to user A according to certain selection rules, that is,<b4、b5、b6> Corresponding products (such as Figure 3B ).
[0114] In another example, Figure 3CAs shown in the figure, user A browsed five items in a certain period of time, such as in a certain day, which is represented as a historical behavior data sequence<a1、a2、a3、a4、a5> , input it into the trained data model to obtain the browsing preference data of user A, such as the browsing preference characteristics of user A<U1、U2、U3> . Suppose, there are ten items to be recommended, represented as a product sequence<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> , then we can calculate<U1、U2、U3> and<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> The degree of association (also known as the degree of matching) of each product in the list is set to obtain 10 association probabilities with the ten products to be recommended. The recommended order of the ten products to be recommended is determined from large to small according to the probability value.<b4、b5、b1、b2、b3、b6、b7、b8、b9、b10> , then ten items can be recommended to user A in this order, or, alternatively, the top three items can be selected as recommended items to user A according to certain selection rules, that is,<b4、b5、b1> Corresponding products.
[0115] In another example, Figure 3D As shown in the figure, user A searches for different contents five times in a certain period of time, such as in a certain day, which is represented as a historical behavior data sequence.<a1、a2、a3、a4、a5> , input it into the trained data model to obtain user A’s search preference data, such as user A’s search preference features<U1、U2、U3> . Suppose, there are ten pieces of information to be recommended, represented as the information sequence<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> , then we can calculate<U1、U2、U3> and<b1、b2、b3、b4、b5、b6、b7、b8、b9、b10> The degree of association of each piece of information in the query (which can also be considered as the degree of matching) is set to obtain 10 association probabilities with the ten pieces of information to be recommended, and the recommended order of the ten pieces of information to be recommended is determined from large to small according to the probability value.<b4、b5、b1、b2、b3、b6、b7、b8、b9、b10> , then ten pieces of information can be recommended to user A in this order, or, alternatively, the top three pieces of information can be selected as the information recommended to user A according to certain selection rules, that is,<b3、b4、b1> Corresponding information.
[0116] In addition, in another example, the server (including but not limited to the cloud, server, server cluster, etc.) can first determine the data that can be recommended to the user based on the user's historical behavior data sequence, but some of these data may not match the user's preferences (such as below a certain threshold), then the data display end (such as the client) can be re-screened according to the user's preferences. Based on this, in a feasible manner, according to the user preference data output by the data model, the target data determined from the preset data to be processed can be implemented as follows: obtaining the recommended data sent by the server, wherein the recommended data is determined by the server according to the user's historical behavior data sequence; according to the user preference data output by the data model, the recommended data is screened, and the target data is determined according to the screening results. In this way, after two rounds of screening by the server and the data display end, more accurate and effective recommendations can be achieved.
[0117] For example, the server determines the recommended data to the user based on the user's historical behavior data sequence<c1、c2、c3、c4、c5、c6、c7、c8、c9、c10> , these data themselves have a certain degree of match or similarity with the user's historical behavior data sequence. After the server sends the above data to the client, the client will then<U1、U2、U3> Filter it, for example,<c4、c5、c6、c7> , then the final display to the user will be<c4、c5、c6、c7> information.
[0118] According to the scheme of this embodiment, the data model is used to output the user preferences, and then the target data is determined from the data to be processed according to the user preference data, so as to realize the application of the user preference data to various scenarios that require subsequent services and applications based on the user preferences. Among them, the preset data to be processed can be the demand data of different services or applications, so that the same user preferences can be used by different services or applications, and each service and application does not need to build dedicated user data that meets its own needs, which reduces the data construction cost and avoids the waste of data processing and use.
[0119] The data model training method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, PCs, etc.
[0120] Embodiment 4
[0121] Reference Figure 4A , shows a step flow chart of a data processing method according to embodiment 4 of the present invention.
[0122] In this embodiment, the data processing method provided in the embodiment of the present invention is described by taking the deployment of the data model on the server side (such as the cloud or server or SaaS platform) and training the data model according to the client request as an example.
[0123] The data processing method of this embodiment includes the following steps:
[0124] Step S301: receiving a model training request sent by a client for requesting training of a preset data model.
[0125] The preset data model is a data model for outputting user preference data, such as the data model described in Embodiment 1 or 2, and the model training request may be in any appropriate form.
[0126] Step S303: Obtain training data according to the model training request.
[0127] In one feasible way, when the data model is deployed on a SaaS (Software-as-a-Service) platform, and the SaaS platform receives a client model training request to train the data model, the training data can be obtained locally from the SaaS platform according to the model training request. In this case, if the SaaS platform has data suitable for data model training stored locally, it can be directly obtained, thereby improving the speed and efficiency of data model training.
[0128] In another feasible way, when the data model is deployed on the SaaS platform and the SaaS platform receives a client model training request to train the data model, the SaaS platform can collect training data from a third party according to the model training request. For example, the training data is obtained from a third-party website or from a data interface provided by a third-party application through the network. In this case, the SaaS platform obtains the training data from a third party without the need for local storage, thus saving storage resources of the SaaS platform.
[0129] In another feasible manner, when the data model is deployed on the SaaS platform and the SaaS platform receives a model training request from the client to train the data model, the SaaS platform can obtain training data from the client according to the model training request. In this case, the training data is stored in the client, and the SaaS platform obtains the training data from the client, so as to train a data model that better meets the client's needs.
[0130] Step S305: Use the training data to train the data model.
[0131] In particular, in a specific implementation, the data model may be trained by the data model training method as described in Embodiment 1 or 2, which will not be described in detail here.
[0132] The following uses the deployment of the data model on the SaaS platform as an example to illustrate the above process. Figure 4B shown.
[0133] Figure 4B In the embodiment, the client sends a model training request to the SaaS platform; after receiving the request, the SaaS platform obtains the training data for training the data model requested by the model training request from the local storage device by the processing device, such as the user's first historical behavior data sequence and the second historical behavior data sequence; the SaaS platform generates a training input sequence as described in the first or second embodiment based on the acquired training data, that is, a training input sequence including the user's first historical behavior data sequence, the second historical behavior data sequence, and the preset characterization header sequence; then, the SaaS platform trains the data model based on the training input sequence, and the trained data model can output user preference data based on the input user behavior data; after completing the training of the data model, the SaaS platform sends a training completion message to the client. Subsequently, if the client has a need, it can send the user behavior data to the SaaS platform to obtain the corresponding user preference data. Optionally, the client can also send the corresponding data of different applications or services to the SaaS platform, so that the SaaS platform can determine the target data based on the data and the user preference data and return it to the client, so that the client can perform subsequent operations, such as recommended operations, etc.
[0134] In the above, the deployment of the data model on the SaaS platform is taken as an example, but those skilled in the art should understand that the solution of this embodiment is also applicable to the case where the data model is deployed on other forms of servers.
[0135] It can be seen that through this embodiment, the data model and its training are deployed on the server, and the server trains the data model according to the client's request, thereby realizing the training of the data model without any requirements for client resources or performance, and ensuring the training effect and efficiency.
[0136] Embodiment 5
[0137] Reference Figure 5 , shows a structural block diagram of a data model training device according to Embodiment 5 of the present invention.
[0138] The data model training device of this embodiment includes: a first acquisition module 402, which is used to obtain a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization head sequence of a user; a first model processing module 404, which is used to input the training input sequence into a data model for obtaining user preference information, vectorize the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; a second model processing module 406, which is used to determine the user preference features of the user based on the data features of the first historical behavior data sequence; and a third model processing module 408, which is used to train the data model based on the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence.
[0139] Optionally, the first acquisition module 402 is used to acquire a user data sequence for training, wherein the user data sequence includes: a first historical behavior data sequence and a second historical behavior data sequence of the user, the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times; a preset representation header sequence is added before the user data sequence to generate the training input sequence.
[0140] Optionally, the first historical behavior data sequence includes multiple historical behavior data groups of the user in a first time period, each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes multiple historical behavior data groups of the user in a second time period, each historical behavior data group includes a behavior object element and a behavior time element; the representation header sequence includes multiple different representation data groups, each representation data group includes a representation element and a preset time element, the representation elements in the multiple representation data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element.
[0141] Optionally, the first time period is earlier than the second time period, and the preset time elements in the multiple characterization data groups are the same.
[0142] Optionally, when the first model processing module 404 vectorizes the training input sequence through the data model, it vectorizes each element in the training input sequence through the data model; and for the elements corresponding to the first historical behavior data sequence after vectorization and the elements corresponding to the representation header sequence, the vectorized elements are merged in units of data groups; and the corresponding training vectors are generated according to the merging results.
[0143] Optionally, the first model processing module 404 is also used to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence before merging the vectorized elements in data groups; perform mask processing on the behavior object elements in the selected historical behavior data groups, and obtain corresponding mask vectors.
[0144] Optionally, when the first model processing module 404 performs feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence, the first model processing module 404 performs feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing through a multi-layer self-attention mechanism to obtain data features corresponding to each data group in the first historical behavior data sequence, and data features corresponding to each data group in the characterization head sequence.
[0145] Optionally, the second model processing module 406 is used to determine the user preference feature of the user according to the data feature corresponding to each data group in the characterization header sequence.
[0146] Optionally, the third model processing module 408 is used to calculate the first difference between the vector corresponding to the user preference feature and the second historical behavior data sequence through a preset noise contrast estimation (NCE) function; and train the data model according to the first difference.
[0147] Optionally, the NCE function is an InfoNCE function.
[0148] Optionally, the third model processing module 408 is also used to perform behavior object prediction on the mask vector based on the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model based on the first difference and the second difference.
[0149] Optionally, the data model includes: an input vector layer, used to convert each element in the training input sequence into a corresponding vector; a vector fusion layer, used to merge the vectors corresponding to the elements corresponding to the first historical behavior data sequence after vectorization processing and the elements corresponding to the characterization header sequence, in units of data groups, and generate the training vector based on the merging result; a feature extraction layer, used to extract and fuse the training vector, and output data features used to characterize the first historical behavior data sequence; a processing layer, used to determine the user preference features of the user based on the data features of the first historical behavior data sequence; determine the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence, and train the data model based on the first difference.
[0150] Optionally, the vector fusion layer is also used to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence; perform mask processing on the behavior object elements in the selected historical behavior data groups, and obtain corresponding mask vectors; the processing layer is also used to perform behavior object prediction on the mask vector based on the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model based on the first difference and the second difference.
[0151] Optionally, the feature extraction layer includes multiple layers, and the multiple feature extraction layers are all Transformer structure layers.
[0152] Optionally, the feature extraction layer is a Bert4Rec structure layer.
[0153] The data model training device of this embodiment is used to implement the corresponding data model training method in the above method embodiment 1 or 2, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here. In addition, the functional implementation of each module in the data model training device of this embodiment can refer to the description of the corresponding part in the above method embodiment, which will not be repeated here.
[0154] Embodiment 6
[0155] Reference Figure 6 , shows a structural block diagram of a data processing device according to embodiment 6 of the present invention.
[0156] The data processing device of this embodiment includes: a second acquisition module 502, used to acquire the user's historical behavior data sequence; an input module 504, used to input the historical behavior data sequence into a data model, wherein the data model is a data model obtained by training the device described in Example 5; a determination module 506, used to determine target data from preset data to be processed based on user preference data output by the data model.
[0157] Optionally, the historical behavior data sequence is the user's historical purchase behavior data sequence, or historical browsing behavior data sequence, or historical search behavior data sequence; the data to be processed is data of objects to be recommended.
[0158] The data processing device of this embodiment is used to implement the corresponding data processing method in the aforementioned method embodiment 3, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here. In addition, the functional implementation of each module in the data processing device of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiment, which will not be described in detail here.
[0159] Embodiment 7
[0160] Reference Figure 7 , shows a structural block diagram of a data processing device according to Embodiment 7 of the present invention.
[0161] The data processing device of this embodiment includes: a receiving module 501, which is used to receive a model training request sent by a client for requesting training of a preset data model; a third acquisition module 503, which is used to obtain training data according to the model training request; a training module 505, which is used to use the training data to train the data model through the device described in Example 5.
[0162] Optionally, the third acquisition module 503 is used to obtain training data locally from the SaaS platform according to the model training request; or, according to the model training request, the SaaS platform collects training data from a third party; or, according to the model training request, the SaaS platform obtains training data from the client.
[0163] The data processing device of this embodiment is used to implement the corresponding data processing method in the fourth embodiment of the aforementioned method, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here. In addition, the functional implementation of each module in the data processing device of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiment, which will not be repeated here.
[0164] Embodiment 8
[0165] Reference Figure 8, shows a schematic diagram of the structure of an electronic device according to Embodiment 8 of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0166] like Figure 8 As shown, the electronic device may include: a processor (processor) 602 , a communication interface (Communications Interface) 604 , a memory (memory) 606 , and a communication bus 608 .
[0167] in:
[0168] The processor 602 , the communication interface 604 , and the memory 606 communicate with each other via a communication bus 608 .
[0169] The communication interface 604 is used to communicate with other electronic devices or servers.
[0170] The processor 602 is used to execute the program 610, and specifically can execute the relevant steps in the above method embodiment.
[0171] Specifically, the program 610 may include program codes, which include computer operation instructions.
[0172] The processor 602 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0173] The memory 606 is used to store the program 610. The memory 606 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0174] In the first implementation:
[0175] Program 610 can be specifically used to enable processor 602 to perform the following operations: obtain a training input sequence including a user's first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization head sequence; input the training input sequence into a data model for obtaining user preference information, vectorize the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; determine the user preference features of the user based on the data features of the first historical behavior data sequence; and train the data model based on the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence.
[0176] In an optional embodiment, the program 610 is also used to enable the processor 602 to obtain a user data sequence for training when obtaining a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation head sequence of the user, wherein the user data sequence includes: the first historical behavior data sequence and the second historical behavior data sequence of the user, the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times; and a preset representation head sequence is added before the user data sequence to generate the training input sequence.
[0177] In an optional embodiment, the first historical behavior data sequence includes multiple historical behavior data groups of the user in a first time period, each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes multiple historical behavior data groups of the user in a second time period, each historical behavior data group includes a behavior object element and a behavior time element; the representation header sequence includes multiple different representation data groups, each representation data group includes a representation element and a preset time element, the representation elements in the multiple representation data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element.
[0178] In an optional implementation, the first time period is earlier than the second time period, and the preset time elements in the multiple characterization data groups are the same.
[0179] In an optional embodiment, the program 610 is also used to enable the processor 602 to vectorize each element in the training input sequence through the data model when vectorizing the training input sequence through the data model; and for the elements corresponding to the first historical behavior data sequence after vectorization and the elements corresponding to the representation header sequence, the vectorized elements are merged in units of data groups; and the corresponding training vectors are generated according to the merging results.
[0180] In an optional embodiment, the program 610 is also used to enable the processor 602 to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence before merging the vectorized elements in units of data groups; mask the behavior object elements in the selected historical behavior data groups, and obtain the corresponding mask vectors.
[0181] In an optional embodiment, program 610 is also used to enable processor 602 to perform feature extraction and fusion processing on the first historical behavior vector and characterization head vector obtained after vectorization processing to obtain data features used to characterize the first historical behavior data sequence, and to perform feature extraction and fusion processing on the first historical behavior vector and characterization head vector obtained after vectorization processing through a multi-layer self-attention mechanism to obtain data features corresponding to each data group in the first historical behavior data sequence, and data features corresponding to each data group in the characterization head sequence.
[0182] In an optional embodiment, program 610 is also used to enable processor 602 to determine the user preference characteristics of the user based on the data characteristics of the first historical behavior data sequence, and to determine the user preference characteristics of the user based on the data characteristics corresponding to each data group in the characterization header sequence.
[0183] In an optional embodiment, the program 610 is further used to enable the processor 602 to calculate the first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence through a preset noise contrast estimation NCE function when training the data model according to the first difference between the user preference feature and the data feature corresponding to the second behavior data; train the data model according to the first difference,
[0184] In an optional implementation, the NCE function is an InfoNCE function.
[0185] In an optional embodiment, the program 610 is also used to enable the processor 602 to perform behavior object prediction on the mask vector based on the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model based on the first difference and the second difference.
[0186] In an optional embodiment, the data model includes: an input vector layer, which is used to convert each element in the training input sequence into a corresponding vector; a vector fusion layer, which is used to merge the vectors corresponding to the elements corresponding to the first historical behavior data sequence after vectorization processing and the elements corresponding to the characterization header sequence, in units of data groups, and generate the training vector based on the merging result; a feature extraction layer, which is used to extract and fuse the training vector, and output data features used to characterize the first historical behavior data sequence; a processing layer, which is used to determine the user preference features of the user based on the data features of the first historical behavior data sequence; determine the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence, and train the data model based on the first difference.
[0187] In an optional embodiment, the vector fusion layer is also used to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence; perform mask processing on the behavior object elements in the selected historical behavior data groups, and obtain corresponding mask vectors; the processing layer is also used to perform behavior object prediction on the mask vector based on the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model based on the first difference and the second difference.
[0188] In an optional implementation, the feature extraction layer includes multiple layers, and the multiple feature extraction layers are all Transformer structure layers.
[0189] In an optional implementation, the feature extraction layer is a Bert4Rec structure layer.
[0190] In the second implementation:
[0191] Program 610 can be specifically used to enable the processor 602 to perform the following operations: obtain a user's historical behavior data sequence; input the historical behavior data sequence into a data model, wherein the data model is a data model trained according to the method described in the first embodiment; and determine target data from preset data to be processed based on user preference data output by the data model.
[0192] In an optional implementation, the historical behavior data sequence is the user's historical purchase behavior data sequence, or historical browsing behavior data sequence, or historical search behavior data sequence; the data to be processed is data of objects to be recommended.
[0193] In an optional implementation, the program 610 is further configured to enable the processor 602 to train the data model using the historical behavior data of multiple users before acquiring the historical behavior data sequence of the user.
[0194] In an optional embodiment, the program 610 is also used to enable the processor 602 to obtain a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization head sequence of the user when training the data model using the user historical behavior data of multiple users; input the training input sequence into the data model for obtaining user preference information, vectorize the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; determine the user preference features of the user based on the data features of the first historical behavior data sequence; and train the data model based on the first difference between the user preference features and the vector corresponding to the second historical behavior data sequence. In a third embodiment:
[0195] Program 610 can be specifically used to enable the processor 602 to perform the following operations: receive a model training request sent by a client for requesting training of a preset data model; obtain training data according to the model training request; and use the training data to train the data model through the data model training method described in the first embodiment.
[0196] In an optional embodiment, program 610 is also used to enable processor 602 to obtain training data locally from the SaaS platform according to the model training request when obtaining training data according to the model training request; or, according to the model training request, the SaaS platform collects training data from a third party; or, according to the model training request, the SaaS platform obtains training data from the client.
[0197] The specific implementation of each step in program 610 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0198] Through the electronic device of this embodiment, the data model can be applied to various scenarios that require subsequent services and applications based on user preferences, and the same user preferences can be used by different services or applications. Each service and application does not need to build dedicated user data to meet its own needs, which reduces data construction costs and avoids waste in data processing and use.
[0199] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0200] The above-described method according to an embodiment of the present invention may be implemented in hardware, firmware, or may be implemented as software or computer code that may be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or may be implemented as computer code that is originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded via a network and will be stored in a local recording medium, so that the method described herein may be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that a computer, processor, microprocessor controller, or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, processor, or hardware, the data model training method or data processing method described herein is implemented. In addition, when a general-purpose computer accesses code for implementing the data model training method or data processing method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the data model training method or data processing method shown herein.
[0201] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0202] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A data processing method, comprising: Obtain the user's historical behavior data sequence; Inputting the historical behavior data sequence into a data model, wherein the data model is used to determine the user preference data of the user according to the historical behavior data, and the data model is obtained by training based on a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation head sequence of the user used for model training, wherein the preset representation head sequence is an initial data sequence representing user preferences, and the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times; Determining target data from preset data to be processed according to the user preference data output by the data model; Among them, the first historical behavior data sequence includes multiple historical behavior data groups of the user in the first time period, and each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes multiple historical behavior data groups of the user in the second time period, and each historical behavior data group includes a behavior object element and a behavior time element; the representation header sequence includes multiple different representation data groups, each representation data group includes a representation element and a preset time element, the representation elements in the multiple representation data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element.
2. The method according to claim 1, wherein: The historical behavior data sequence is the user's historical purchase behavior data sequence, or historical browsing behavior data sequence, or historical search behavior data sequence; the data to be processed is the data of the object to be recommended.
3. The method according to claim 1, wherein: Before obtaining the user's historical behavior data sequence, the method further includes: The data model is trained using historical user behavior data of multiple users.
4. The method according to claim 3, wherein: The using the user historical behavior data of multiple users to train the data model includes: Acquire a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation header sequence of the user; Inputting the training input sequence into a data model for obtaining user preference information, performing vectorization processing on the training input sequence through the data model, and performing feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; determining a user preference feature of the user according to the data feature of the first historical behavior data sequence; The data model is trained according to a first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence.
5. The method according to claim 1, wherein: The target data determined from the preset data to be processed according to the user preference data output by the data model includes: Acquire recommendation data sent by the server, wherein the recommendation data is determined by the server according to the historical behavior data sequence of the user; The recommended data is screened according to the user preference data output by the data model, and the target data is determined according to the screening result.
6. A data model training method, comprising: Obtaining a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation head sequence of a user, wherein the preset representation head sequence is an initial data sequence representing user preferences, and the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times; Inputting the training input sequence into a data model for obtaining user preference information, performing vectorization processing on the training input sequence through the data model, and performing feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; determining a user preference feature of the user according to the data feature of the first historical behavior data sequence; Training the data model according to a first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence; Among them, the first historical behavior data sequence includes multiple historical behavior data groups of the user in the first time period, and each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes multiple historical behavior data groups of the user in the second time period, and each historical behavior data group includes a behavior object element and a behavior time element; the representation header sequence includes multiple different representation data groups, each representation data group includes a representation element and a preset time element, the representation elements in the multiple representation data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element.
7. The method according to claim 6, wherein: The step of obtaining a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset representation header sequence of a user includes: Acquire a user data sequence for training, wherein the user data sequence includes: a first historical behavior data sequence and a second historical behavior data sequence of the user; A preset characterization header sequence is added before the user data sequence to generate the training input sequence.
8. The method according to claim 6, wherein: The first time period is earlier than the second time period, and the preset time elements in the multiple characterization data groups are the same.
9. The method according to claim 6, wherein: The vectorizing the training input sequence by using the data model includes: Each element in the training input sequence is vectorized by the data model; and the elements corresponding to the first historical behavior data sequence after vectorization and the elements corresponding to the representation header sequence are merged in units of data groups; and the corresponding training vector is generated according to the merging result.
10. The method according to claim 9, wherein: Before merging the vectorized elements in units of data groups, the method further includes: Randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence; perform mask processing on the behavior object elements in the selected historical behavior data groups, and obtain corresponding mask vectors.
11. The method according to any one of claims 6 to 10, wherein: The step of performing feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence includes: The first historical behavior vector and the representation head vector obtained after the vectorization processing are subjected to feature extraction and fusion processing through a multi-layer self-attention mechanism to obtain data features corresponding to each data group in the first historical behavior data sequence, and data features corresponding to each data group in the representation head sequence.
12. The method according to claim 11, wherein: The determining the user preference feature of the user according to the data feature of the first historical behavior data sequence includes: The user preference feature of the user is determined according to the data feature corresponding to each data group in the characterization header sequence.
13. The method according to claim 6, wherein: Training the data model according to a first difference between the user preference feature and a data feature corresponding to the second historical behavior data includes: Calculating a first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence by using a preset noise contrast estimation (NCE) function; The data model is trained according to the first difference.
14. The method according to claim 13, wherein: The NCE function is an InfoNCE function.
15. The method according to claim 10, wherein: The method further comprises: performing behavior object prediction on the mask vector according to the result of the feature extraction and fusion processing, and determining a second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; The training of the data model includes: training the data model according to the first difference and the second difference.
16. The method according to claim 9, wherein: The data model includes: An input vector layer, used to convert each element in the training input sequence into a corresponding vector; A vector fusion layer is used to merge the vectors corresponding to the elements corresponding to the first historical behavior data sequence after vectorization and the elements corresponding to the representation header sequence, in units of data groups, after the input vector layer transforms the elements, and generate the training vector according to the merged result; A feature extraction layer, used for performing feature extraction and fusion processing on the training vectors, and outputting data features for characterizing the first historical behavior data sequence; A processing layer is used to determine the user preference characteristics of the user based on the data characteristics of the first historical behavior data sequence; determine the first difference between the user preference characteristics and the vector corresponding to the second historical behavior data sequence, and train the data model based on the first difference.
17. The method according to claim 16, wherein: The vector fusion layer is further used to randomly select some historical behavior data groups from multiple historical behavior data groups in the first historical behavior data sequence; perform mask processing on the behavior object elements in the selected historical behavior data groups, and obtain corresponding mask vectors; The processing layer is also used to perform behavior object prediction on the mask vector based on the results of the feature extraction and fusion processing, and determine the second difference between the prediction result of the behavior object prediction and the behavior object element corresponding to the mask vector; and train the data model based on the first difference and the second difference.
18. The method according to claim 16 or 17, wherein: The feature extraction layer includes multiple layers, and the multiple feature extraction layers are all Transformer structure layers.
19. The method according to claim 16 or 17, wherein: The feature extraction layer is a Bert4Rec structure layer.
20. A data processing method, comprising: Receive a model training request sent by a client for requesting training of a preset data model; Acquire training data according to the model training request; Using the training data, the data model is trained by the data model training method according to any one of claims 6 to 19.
21. The method according to claim 20, wherein: The acquiring of training data according to the model training request includes: According to the model training request, training data is obtained locally from the SaaS platform; or, According to the model training request, the SaaS platform collects training data from a third party; or, According to the model training request, the SaaS platform obtains training data from the client.
22. A data model training device, comprising: A first acquisition module is used to acquire a training input sequence including a first historical behavior data sequence, a second historical behavior data sequence, and a preset characterization header sequence of a user, wherein the preset characterization header sequence is an initial data sequence representing user preferences, the first historical behavior data sequence and the second historical behavior data sequence are sequences corresponding to the behavior data of the user at different times, the first historical behavior data sequence includes a plurality of historical behavior data groups of the user in a first time period, each historical behavior data group includes a behavior object element and a behavior time element; the second historical behavior data sequence includes a plurality of historical behavior data groups of the user in a second time period, each historical behavior data group includes a behavior object element and a behavior time element; the characterization header sequence includes a plurality of different characterization data groups, each characterization data group includes a characterization element and a preset time element, the characterization elements in the plurality of characterization data groups are different, and the time indicated by the preset time element is earlier than the time indicated by the behavior time element; A first model processing module is used to input the training input sequence into a data model for obtaining user preference information, perform vectorization processing on the training input sequence through the data model, and perform feature extraction and fusion processing on the first historical behavior vector and the characterization head vector obtained after the vectorization processing to obtain data features for characterizing the first historical behavior data sequence; A second model processing module, used to determine the user preference characteristics of the user according to the data characteristics of the first historical behavior data sequence; The third model processing module is used to train the data model according to the first difference between the user preference feature and the vector corresponding to the second historical behavior data sequence.
23. A data processing device, comprising: The second acquisition module is used to acquire the user's historical behavior data sequence; An input module, used to input the historical behavior data sequence into a data model, wherein the data model is a data model obtained by training the device according to claim 22; The determination module is used to determine target data from preset data to be processed according to the user preference data output by the data model.
24. A data processing device, comprising: A receiving module, used to receive a model training request sent by a client for requesting training of a preset data model; A third acquisition module is used to acquire training data according to the model training request; A training module, used to use the training data to train the data model through the device as described in claim 22.
25. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the data processing method described in any one of claims 1-5; or, to perform operations corresponding to the data model training method described in any one of claims 6-19; or, to perform operations corresponding to the data processing method described in any one of claims 20-21.
26. A computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the data processing method as described in any one of claims 1 to 5; or, implements the data model training method as described in any one of claims 6 to 19; or, implements the data processing method as described in any one of claims 20 to 21.
Citation Information
Patent Citations
A method and apparatus for pushing information
CN109460514A
Model training system and method and storage medium
CN109840591A
