Online group recommendation method and system based on multi-scale contrastive learning twin tower model
By introducing a multi-scale comparative learning dual-tower model in the group recommendation system, the problem of not being able to fully utilize user historical behavior data and online group characteristics in the existing technology is solved, and a more accurate and personalized group recommendation effect is achieved.
Patent Information
- Application Number
- CN202411455437.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-18
AI Technical Summary
The existing group recommendation methods and systems cannot fully utilize user historical behavior data and online group characteristics, and ignore the key role of similar users in recommendations, making it difficult to make personalized group recommendations.
A method for online group recommendation based on multi-scale comparative learning double tower model is proposed. By constructing the left and right towers of the multi-scale comparative learning double tower model, the user-group interaction sequence and candidate groups are encoded respectively, and multi-head attention is used Force mechanism and two-level aggregation mechanism capture the complex relationship between users and groups, and learn unsupervised signals through comparative learning networks.
By enhancing the cooperative relationship between sequence coding and group coding, the model can more accurately understand user preferences and group characteristics, improve the personalization and accuracy of recommendations, and overcome the problems of data sparseness and supervised signal sparseness.
Smart Images

Figure CN118964748B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to an online group recommendation method and system based on a multi-scale contrastive learning twin-tower model. Background Art
[0002] On event-based social networking platforms such as Meetup and Douban, online groups are not only virtual communities for users to share experiences, exchange knowledge, and establish connections, but also an important way for users to discover and participate in offline events. With the surge in the number of groups, users' demand for online group recommendation services has become more urgent. Providing users with high-quality online group recommendations can help alleviate the problem of user information overload, thereby improving user satisfaction with platform services.
[0003] Currently, existing group recommendation methods and systems mainly use deep self-attention technology to model user behavior sequences, and have made significant progress in accuracy and efficiency. However, they still have the following defects: (1) They do not notice that the groups in which users participate contain many similar users, and ignore that similar users are important related factors for discovering users' future participation in groups. (2) Recommended groups are different from general items and have their own unique characteristics. For example, groups contain published events, and events are completed by group members. Existing methods have not fully explored these characteristics, which affects the accuracy of group representation learning. (3) Traditional deep learning technology requires a large amount of training data, but in group recommendation, most users only interact with a limited number of groups in a large number of groups. This data sparsity problem constitutes a bottleneck that prevents existing models from fully exerting their functions.
[0004] Therefore, existing group recommendation methods and systems cannot make full use of the potential relationship between similar user preferences and user preferences based on user historical behavior data and online group characteristics, making it difficult to make personalized group recommendations. Summary of the invention
[0005] Based on this, the present application proposes an online group recommendation method and system based on a multi-scale contrastive learning dual-tower model, aiming to solve the problem that existing group recommendation methods and systems cannot make full use of the potential relationship between similar user preferences and user preferences based on user historical behavior data and online group characteristics, resulting in difficulty in making personalized group recommendations.
[0006] The first aspect of the present application provides an online group recommendation method based on a multi-scale contrastive learning twin-tower model, the method comprising:
[0007] Obtaining relevant information of online group recommendation, preprocessing the relevant information, and obtaining a user group sequence, a user initial representation, an event initial representation, and a neighbor set of the user and the event;
[0008] Construct a multi-scale contrastive learning dual-tower model, including:
[0009] Constructing a left tower of a multi-scale contrastive learning dual-tower model, including a sequence coding network, wherein the sequence coding network includes a group embedding coding layer, a sequence initial coding layer and a similar user coding layer, wherein the group embedding coding layer is used to obtain a group embedding representation according to a group sequence of a user, the sequence initial coding layer is used to obtain an initial group coding sequence according to the group embedding representation, and the similar user coding layer is used to obtain a group coding sequence according to the initial group coding sequence;
[0010] Constructing a right tower of a multi-scale contrastive learning dual-tower model, including a group coding network, wherein the group coding network includes an opinion fusion layer and a feature aggregation layer, wherein the opinion fusion layer is used to obtain a final representation of each node according to an initial representation of a user, an initial representation of an event, and a neighbor set of the user and the event, and the feature aggregation layer is used to obtain a final representation of the group according to the final representation of each node;
[0011] Constructing a contrastive learning network of a multi-scale contrastive learning dual-tower model, including a group-group contrast layer, a sequence-sequence contrast layer, and a sequence-group contrast layer, wherein the group-group contrast layer is used to construct a group contrast loss function, the sequence-sequence contrast layer is used to construct a sequence contrast loss function, and the sequence-group contrast layer is used to construct a sequence-group contrast loss function;
[0012] Constructing an optimization loss function to train the multi-scale contrastive learning twin-tower model to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function, and the sequence-group contrast loss function;
[0013] The online group recommendation result is obtained based on the multi-scale contrastive learning dual-tower optimization model.
[0014] As an optional implementation of the first aspect, the method further includes formally defining an online group recommendation method:
[0015] Defining online networks ,in and Respectively represent the user node set and the online group node set, represents the online edge set;
[0016] Defining offline networks ,in and Represent the user node set and offline event node set respectively, represents the offline edge set;
[0017] Defining Users Online group sequence , Indicates user In time step Join online groups, Indicates the length of the sequence;
[0018] Defining online networks , offline network and users Online group sequence As input to the multi-scale contrastive learning twin-tower model;
[0019] definition The online groups with the highest prediction scores are output as recommendation results;
[0020] Define the objective function ,in Represents the calculation of user pairs in a group The preference score of Indicates user In time step Online groups to join.
[0021] As an optional implementation manner of the first aspect, the step of the group embedding coding layer for obtaining a group embedding representation according to a group sequence of a user includes:
[0022] Embedding learnable positions Injected into the user's group sequence Groups in In the above example, we get the sequence representation of each position. ;
[0023] Represent the sequence at each position Stacked into a matrix , That is the group embedding representation.
[0024] As an optional implementation manner of the first aspect, the step of the sequence initial coding layer for obtaining an initial group coding sequence according to the group embedding representation includes:
[0025] Use a Transformer layer in the initial encoding layer of the sequence and calculate the group embedding representation for each position in each layer of the Transformer layer ;
[0026] Representing the group embedding at each position Stacked into a matrix , , represents the depth of the Transformer layer, This is the initial group coding sequence.
[0027] As an optional implementation manner of the first aspect, the step of using the similar user coding layer to obtain a group coding sequence according to an initial group coding sequence includes:
[0028] A similar user-aware multi-head attention mechanism is used in the similar user encoding layer to obtain User preferences at the Lth Transformer layer ;
[0029] The With the After concatenation, the group coding sequence is obtained through the fully connected layer. .
[0030] As an optional implementation manner of the first aspect, the step of the opinion fusion layer being used to obtain a final representation of each node according to an initial representation of the user, an initial representation of the event, and a neighbor set of the user and the event includes:
[0031] In the opinion fusion layer, the GAT layer is used to embed the user initial representation, event initial representation, and the neighbor set of users and events into the GAT layer to obtain the node With adjacent nodes Similarity ;
[0032] Based on the similarity , use the multi-head attention mechanism to represent the splicing and get the node The final representation .
[0033] As an optional implementation manner of the first aspect, the step of the feature aggregation layer being used to obtain a final representation of the group according to a final representation of each node includes:
[0034] Node-based The final representation , using a one-level multi-head attention mechanism to aggregate user features into event features ;
[0035] Then use the secondary multi-head attention mechanism to Aggregation to obtain the final representation of the group .
[0036] As an optional implementation manner of the first aspect, the optimization loss function ;
[0037] in is a hyperparameter used to control the strength of the contrastive loss, represents the negative log-likelihood loss function, represents the total contrast loss function;
[0038] ,in, represents the group contrast loss function, represents the sequence contrast loss function, represents the sequence-group contrast loss function;
[0039] ,in, Indicates the time step The truth value of Indicates that the sequence A subsequence of groups, Before A collection of groups.
[0040] A second aspect of an embodiment of the present application provides an online group recommendation system based on a multi-scale contrastive learning twin-tower model, the system comprising:
[0041] A data acquisition module is used to acquire relevant information of online group recommendation, pre-process the relevant information, and obtain the user's group sequence, user initial representation, event initial representation, and neighbor sets of users and events;
[0042] A model building module is used to build a multi-scale contrastive learning twin-tower model, wherein the multi-scale contrastive learning twin-tower model includes:
[0043] A sequence coding network unit, the sequence coding network unit comprising:
[0044] The group embedding encoding layer is used to obtain the group embedding representation according to the user's group sequence;
[0045] The sequence initial coding layer is used to obtain the initial group coding sequence according to the group embedding representation;
[0046] A similar user coding layer, used to obtain a group coding sequence according to an initial group coding sequence;
[0047] A group coding network unit, the group coding network unit comprising:
[0048] The opinion fusion layer is used to obtain the final representation of each node based on the initial representation of the user, the initial representation of the event, and the neighbor sets of the user and the event;
[0049] The feature aggregation layer is used to obtain the final representation of the group based on the final representation of each node;
[0050] A contrastive learning network unit, the contrastive learning network unit comprising:
[0051] Group-group comparison layer, used to construct the group comparison loss function;
[0052] Sequence-sequence comparison layer, used to construct the sequence comparison loss function;
[0053] The sequence-group contrast layer is used to construct the sequence-group contrast loss function;
[0054] Constructing a training function module, which is used to construct an optimization loss function to train the multi-scale contrastive learning twin-tower model to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function, and the sequence-group contrast loss function;
[0055] The recommendation prediction module is used to obtain online group recommendation results based on the multi-scale contrastive learning dual-tower optimization model.
[0056] A third aspect of an embodiment of the present application provides a computer device, which includes a memory, a processor, and a processing program stored in the memory and executable on the processor, wherein the processing program implements the online group recommendation method when executed by the processor.
[0057] A fourth aspect of the embodiments of the present application provides a storage medium, on which a processing program is stored. When the processing program is executed by a processor, the online group recommendation method is executed.
[0058] Advantages of the present invention:
[0059] (1) In response to the problem that existing methods ignore the key role of similar users in recommendation, this paper proposes a recommendation method based on a dual-tower model. The method adopts a dual-tower architecture, in which the left tower encodes the user-group interaction sequence and the right tower encodes the candidate group. For the left tower, the user's similar user information is integrated into the sequence encoder by using a multi-head attention mechanism; for the right tower, the relevant user information is aggregated into the group encoder by using a two-level aggregation mechanism. In this way, when a candidate group contains many similar users, the features extracted by the sequence encoder and the features extracted by the group encoder will contain a lot of the same information, so that the candidate group has a greater probability of being recommended to the target user.
[0060] (2) In view of the fact that the recommended groups not only contain published events but also have member users, the present invention introduces a two-level aggregation mechanism to hierarchically aggregate features from different entities. Specifically, user features are first aggregated into low-level event features, and then these event features are aggregated into higher-level group features. Since the events published by the group indicate the interests of the group, and the users who participate in the event reflect the style or taste of the event, a more accurate group representation can be obtained by hierarchically aggregating user and event features.
[0061] (3) In order to solve the problem of sparsity of supervised signals in traditional deep learning, the present invention designs a multi-scale contrastive learning framework in combination with the dual-tower model architecture. Sequence-sequence comparison is performed in the left tower, group-group comparison is performed in the right tower, and sequence-group comparison is performed between the two towers. This design can capture richer semantics in unsupervised signals and enhance the semantics of data representation. More importantly, it further strengthens the cooperative association between sequence encoding and group encoding, allowing the model to consider the preferences of similar users who join the candidate group more when making recommendations.
[0062] Additional aspects and advantages of the present application will be given in part in the following description, and in part will become apparent from the following description, or will be understood through the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 A flowchart of an online group recommendation method based on a multi-scale contrastive learning twin-tower model proposed in the first embodiment of the present application;
[0064] Figure 2 A network architecture diagram of a multi-scale contrastive learning dual-tower model proposed in the first embodiment of the present application;
[0065] Figure 3 This is a schematic diagram of the structure of an online group recommendation system based on a multi-scale contrastive learning twin-tower model proposed in the second embodiment of the present application.
[0066] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0067] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0068] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here. In addition, the "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally represents that the objects associated with each other are in an "or" relationship.
[0069] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.
[0070] See also Figure 1 , is a flowchart of an online group recommendation method based on a multi-scale contrastive learning twin-tower model proposed in the first embodiment of the present application, wherein the proposed method includes:
[0071] S01: Obtain relevant information of online group recommendation, pre-process the relevant information, and obtain a user group sequence, a user initial representation, an event initial representation, and a neighbor set of the user and the event.
[0072] For example, the relevant information recommended by the online group can be collected from the EBSN website by crawler technology and API. The data in EBSN mainly includes user demographic information, event description information, offline network user event participation records, online network user participation interest group records, interest group description information, time information, location information, etc.
[0073] Preprocessing is the basis and important part of group recommendation, providing the basis and support for the next step of recommendation generation. It mainly includes common operations such as data merging, data cleaning, data standardization and data conversion, and also involves the selection and representation of contextual features, social network construction, group data screening, and the establishment of associations between different objects (such as events, users, interest groups, organizers, etc.).
[0074] To facilitate the description of this solution, we first give the concepts and formal definitions related to the problem in this solution. The details are as follows:
[0075] Defining online networks ,in and Respectively represent the user node set and the online group node set, represents the online edge set; if a user Join an online group , then in this network and There is an edge between them.
[0076] Defining offline networks ,in and Represent the user node set and offline event node set respectively, represents the offline edge set; if a user Join an online group , then in this network and There is an edge between them.
[0077] Defining Users Online group sequence , Indicates user In time step Join online groups, Indicates the length of the sequence; if a user Join an offline event , then in this network and There is also an edge between them.
[0078] Defining online networks , offline network and users Online group sequence As input to the multi-scale contrastive learning twin-tower model;
[0079] definition The online groups with the highest prediction scores are output as recommendation results;
[0080] Given a target user , defining the target as the prediction In time step Most likely to join online group, the problem is formalized as follows:
[0081] , (1)
[0082] in It is recommended to the user A collection of online groups, Represents the calculation of user pairs in groups preference score.
[0083] S02: Construct a multi-scale contrastive learning twin-tower model;
[0084] like Figure 2The figure shows the network architecture of the multi-scale contrastive learning dual-tower model. The left tower (i.e., sequence encoding network) in the figure stacks multiple enhanced Transformer encoders, aiming to capture the dependencies in the user behavior sequence. In particular, it integrates similar user features of the target users and captures the dynamic changes of similar users. The right tower (i.e., group encoding network) in the figure introduces a two-level aggregation mechanism to obtain group representation. First, user features are aggregated into event features, and then event features are aggregated to obtain the final group representation. The contrastive learning network in the figure designs a multi-scale contrastive learning framework. The same-scale comparison includes group-group and sequence-sequence comparison, which are performed in the right tower and left tower respectively. The cross-scale comparison is sequence-group comparison, which is performed between the two towers.
[0085] Depend on Figure 1 , Figure 2 It can be seen that step S02 specifically includes:
[0086] S021: Constructing the left tower of a multi-scale contrastive learning dual-tower model, including a sequence coding network, wherein the sequence coding network includes a group embedding coding layer, a sequence initial coding layer and a similar user coding layer, wherein the group embedding coding layer is used to obtain a group embedding representation according to the user's group sequence, the sequence initial coding layer is used to obtain an initial group coding sequence according to the group embedding representation, and the similar user coding layer is used to obtain a group coding sequence according to the initial group coding sequence.
[0087] It should be noted that the purpose of the sequence encoding network is to obtain sequence representations for the target user. Specifically, the user's group sequence is first input into the embedding layer to obtain the embedded representations of each group in the sequence. Then, the Transformer unidirectional encoder is used to obtain the initial sequence information. Finally, in order to capture the dynamically changing similar user characteristics, a similar user-aware multi-head attention mechanism is adopted. Specifically, it can be divided into three steps: group embedding encoding layer, sequence initial encoding layer, and similar user encoding layer.
[0088] In the group embedding encoding layer, the learnable positions are embedded Injected into the user's group sequence Groups in In the above example, we get the sequence representation of each position. ; Characterize the sequence at each position Stacked into a matrix , That is the group embedding representation.
[0089] Specifically, Indicates the target user Online interactive group sequence (where is the sequence length). In order to exploit the order information of the input sequence, the learnable position embedding is injected into the group embedding. Group , whose input representation The construction is as follows:
[0090] , (2)
[0091] in Is a group of dimensional embedding, is the position index This scheme uses sinusoid embedding as the position encoding method. Then, the Stacked into a matrix , and use it as the initial input to the first Transformer layer.
[0092] At the initial encoding layer of the sequence, use the Transformer layer and calculate the group embedding representation for each position in each layer of the Transformer layer ; Embed the group representation at each position Stacked into a matrix , , represents the depth of the Transformer layer, This is the initial group coding sequence.
[0093] Specifically, the Transformer layers are applied iteratively, and the group representation of each position in each layer is calculated, and the representation of each position is stacked into a matrix ( , is the depth of the Transformer layer) in order to calculate the attention function related to all positions. The Transformer layer Trm contains two sublayers: the multi-head self-attention sublayer (MH) and the position feed-forward network (PFFN). In order to learn more complex transfer patterns, the Transformer layers are stacked, and widely used mechanisms such as residual connections, layer normalization, and dropout are used to accelerate model training. The hidden representation of each layer is calculated as follows:
[0094] , (3)
[0095] , (4)
[0096] , (5)
[0097] in represents the Transformer layer, represents the point-forward network sublayer, represents the multi-head self-attention sublayer with dropout and layer normalization, , , They represent layer normalization, dropout, and multi-head self-attention operations respectively.
[0098] In the similar user encoding layer, a multi-head attention mechanism with similar user perception is adopted to obtain User preferences for the Lth boosted Transformer layer ; With the After concatenation, the group coding sequence is obtained through the fully connected layer. .
[0099] Specifically, in order to incorporate similar user information of the target user into the sequence encoder, a similar user-aware multi-head attention mechanism is adopted. First, the similar user set of a user at a specific time step is defined as the set of member users of all groups that the user joined before the time step. Then, the multi-head attention mechanism is defined as follows:
[0100] , (6)
[0101] , (7)
[0102] , (8)
[0103] in Indicates the time step User preferences of the Lth Transformer layer, which has integrated similar user information. is the output of the Lth Transformer layer No. A characterization of a group of elements. represents transpose, Represents a concatenation operation. Is a user In time step The embedding matrix of similar user sets is Is a user As mentioned above, this scheme will Similar users are defined as and Users who join the same group, therefore, Depend on In time step The similar users in the group that have joined before. In fact, in order to improve the calculation efficiency, this scheme only considers the previous The most similar users, that is, The top 100 most common groups Users. Projection Matrix , , , are learnable parameters, where is the number of attention heads, represents the multi-head attention function, The meaning of is shown in the second equal sign of formula (7). Normalize the input category value. The specific calculation formula is: ,in Represents an exponential function.
[0104] Next, all time steps Stacked into a matrix , and then combine this matrix with the sequence information Concatenate them together and input the result into a fully connected network. The specific calculation is as follows:
[0105] , (9)
[0106] in The output is Fully connected network.
[0107] The above Transformer layer that integrates similar user features is called an enhanced Transformer layer. In order to learn representations at different levels of abstraction, multiple enhanced Transformer layers are stacked to ultimately obtain more effective group sequence encoding.
[0108] S022: Construct the right tower of the multi-scale contrastive learning dual-tower model, including a group coding network, wherein the group coding network includes an opinion fusion layer and a feature aggregation layer, wherein the opinion fusion layer is used to obtain the final representation of each node according to the user initial representation, the event initial representation, and the neighbor set of the user and the event, and the feature aggregation layer is used to obtain the final representation of the group according to the final representation of each node.
[0109] It should be noted that the group coding network aims to obtain the final representation of the group. It includes the opinion fusion layer and the feature aggregation layer. The opinion fusion layer aims to model the offline association process between users to obtain the representation of users and events; the feature aggregation adopts a two-level aggregation mechanism to aggregate features from different entities in layers. The details are as follows:
[0110] In the opinion fusion layer, the graph attention network GAT layer is used to embed the user initial representation, event initial representation, and the neighbor set of users and events into the graph attention network GAT layer to obtain the node Neighboring nodes Similarity Based on the similarity , use the multi-head attention mechanism to represent the splicing and get the node The final representation .
[0111] Specifically, users meet each other and exchange ideas in offline events. In order to distinguish the influence of different users, this scheme uses GAT (graph attention networks) to guide the spread of influence and obtain the initial representation of users and events. Formally, for a given node in a GAT layer , according to the attention mechanism, calculate its relationship with the adjacent nodes Similarity , for example, given the node Can be represented as users, adjacent nodes It is represented as a user node An event that you participate in offline. The specific calculation process is as follows:
[0112] , (10)
[0113] , (11)
[0114] in, and Node and The initial embedding representation of It is a node The set of neighbor nodes in the offline network, is a linear transformation, It is a single-layer feedforward neural network with the output The dimension is 1. represents the exponential function, is a non-linear activation function.
[0115] After obtaining the above normalized similarity, the multi-head attention mechanism is used for message passing. Specifically, Each independent attention mechanism performs a linear transformation and applies a nonlinear activation function on these transformations. Afterwards, the obtained representations are concatenated to produce nodes The following output representation :
[0116] , (12)
[0117] in, Indicates splicing, is the Sigmoid activation function, It is The normalized similarity weight calculated by the attention mechanism, is the weight matrix of the corresponding input linear transformation, is the number of attention heads. By stacking multiple attention layers This scheme obtains the final representation of each node. In particular, this scheme converts user nodes The final representation of , the event node The final representation of For simplicity, the subscripts of the identification layers are omitted here. .
[0118] At the feature aggregation layer, based on the node The final representation , using a one-level multi-head attention mechanism to aggregate user features into event features ; Use the two-level multi-head attention mechanism to Aggregation to obtain the final representation of the group .
[0119] Specifically, the goal of feature aggregation is to obtain the final representation of the group. In an online EBSN group, the organizer publishes events within the group and organizes users to participate in offline events. Since the events published by the group indicate the interest direction of the group, and the users who participate in the event reflect the style or taste of the event, this scheme believes that the final representation of the group can be derived by hierarchically aggregating user and event features. Therefore, this scheme adopts a two-level multi-head attention mechanism to achieve the above goal.
[0120] Specifically, user features are first aggregated into event features using the following one-level multi-head attention:
[0121] , (13)
[0122] in Indicates an event The characteristics of Indicates the events obtained by the GAT layer The presentation of It is composed of The matrix composed of user representations in , Indicate participation in the event users.
[0123] Next, using the same method, we use the second-level multi-head attention to aggregate the event features into the final representation of the group middle:
[0124] , (14)
[0125] in It is composed of The embedding matrix composed of the event representations in Indicates group The collection of events published, Is a group Similar to the similar user encoding in the Zuota sequence encoder, to improve computational efficiency, the scheme only considers the most recent user published in the group events, namely .
[0126] S023: Construct a contrastive learning network of a multi-scale contrastive learning dual-tower model, including a group-group contrast layer, a sequence-sequence contrast layer and a sequence-group contrast layer, wherein the group-group contrast layer is used to construct a group contrast loss function, the sequence-sequence contrast layer is used to construct a sequence contrast loss function, and the sequence-group contrast layer is used to construct a sequence-group contrast loss function.
[0127] It should be noted that this scheme introduces contrastive learning in the recommendation task, which alleviates the sparsity of the supervisory signal while strengthening the cooperative association between the two towers. Specifically, this scheme proposes a multi-scale contrast framework for the dual-tower architecture, which consists of three types of contrasts: group-group contrast, sequence-sequence contrast, and sequence-group contrast. The first two types can be regarded as same-scale contrasts, because the views to be compared are from two objects of the same scale, i.e., group-group or sequence-sequence. The last type can be regarded as cross-scale contrast, because the views to be compared are from two objects of different scales (i.e., sequence-group), and since a sequence contains multiple groups, the sequence can be regarded as a coarser scale compared to the group.
[0128] At the group-group contrast level, for a user, the group in the sequence is the group that is favored by the user. Therefore, this scheme considers two groups from the same sequence as positive sample pairs and two groups from different sequences as negative sample pairs. In practice, in order to avoid calculating the contrast loss between each pair of groups for a given user, the groups in the sequence are split into two disjoint subsets: , . Then, the average group representation of each subset is calculated. The two average group representations from the same sequence are regarded as positive sample pairs, while the average group representations from other sequences in the same training batch are regarded as negative samples. This scheme adopts the existing InfoNCE loss to maximize the consistency of positive sample pairs and minimize the consistency of negative sample pairs. The group contrast loss calculation formula is as follows:
[0129] , (15)
[0130] , , (16)
[0131] , (17)
[0132] in is the set of users in the training batch, is a hyperparameter called temperature. ,and , Respectively represent users and The collection of groups you have joined. is the group obtained by the group encoder representation.
[0133] In the sequence-sequence contrast layer, the input sequence is input twice into the Transformer with a dropout layer, and two different vectors are generated, which are semantically similar but have different characteristics. Therefore, one of the two vectors can be selected as the augmented data of the other vector. In the scheme experiment, the dropout ratio can be set to 0.1. The sequence contrast loss function is defined as follows:
[0134] , (18)
[0135] in Is a user Sequence characterization enhancement, and is the last position index of the sequence.
[0136] In the sequence-group contrast layer, the group sequence as a whole can be regarded as the context of its group elements. In order to capture the intrinsic relationship between the sequence and each group element, the sequence and each of its group elements are brought closer in the embedding space, and the sequence and group elements in other sequences are separated in the embedding space. Similarly, in order to avoid calculation for each individual group, this scheme adopts the batch contrast loss method. The sequence-group contrast loss is calculated as follows:
[0137] , (19)
[0138] , (20)
[0139] S03: Constructing an optimization loss function to train the multi-scale contrastive learning twin-tower model to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function and the sequence-group contrast loss function.
[0140] Combined with the three contrast losses in step S023 above, the objective function (total contrast loss function) of the self-supervised task can be defined as follows:
[0141] ,(twenty one).
[0142] In the stage of constructing the negative log-likelihood loss function, in order to predict the user In time step Most interested in groups, first calculate the inner product of the sequence representation and the group representation as For Groups The preference score is calculated as follows:
[0143] ,(twenty two)
[0144] in Indicates user At time step For Groups The preference score is It is based on N users of the improved Transformer In time step The sequence representation of . is the number of layers in each Transformer. is the group obtained by the group encoder representation.
[0145] Then, the candidate groups are ranked according to the preference scores, and the candidate groups with the highest scores are selected. Recommend groups to users .
[0146] For Users sequence , predict the target group in time order, and use the negative log-likelihood function as the main loss function, which is defined as follows:
[0147] ,(twenty three)
[0148] , (twenty four)
[0149] in is the time step The truth value of is preceded by the sequence groups, and is a collection of these groups.
[0150] Furthermore, a multi-task training strategy is adopted to jointly optimize the main task of sequence recommendation and the auxiliary task of contrastive learning. The total loss is the linear weighted sum of the losses of the two tasks, as shown below:
[0151] , (25)
[0152] in is a hyperparameter used to control the strength of the contrastive loss.
[0153] S04: Obtaining online group recommendation results based on the multi-scale contrastive learning dual-tower optimization model.
[0154] In summary, firstly, this method can effectively extract the user's group sequence, user initial representation, event initial representation, and the neighbor set of users and events by obtaining relevant information of online groups and performing preprocessing. This step provides an accurate data basis for subsequent recommendations and ensures the accuracy and relevance of the recommendation results. In terms of model construction, the design of the multi-scale contrastive learning dual-tower model is particularly ingenious. The sequence coding network in the left tower achieves a deep understanding and representation of the user group sequence through the group embedding coding layer, sequence initial coding layer, and similar user coding layer. This multi-level coding method not only enhances the model's ability to capture user interests, but also improves its ability to handle complex group relationships. The group coding network in the right tower conducts a comprehensive analysis of the interactive relationship between users and events through the opinion fusion layer and feature aggregation layer, obtains the final representation of each node, and then forms the final representation of the group. This structural design enables the model to better understand the user's role and influence in the group, thereby improving the accuracy of recommendations. The design of the contrastive learning network further improves the performance of the model. Through the group-group contrast layer, sequence-sequence contrast layer, and sequence-group contrast layer, the model It can learn effective representations of different groups, sequences and the relationships between them. This contrastive learning mechanism helps the model discover potential patterns in the data, thereby improving the diversity and personalization of recommendations. In the design of the optimization loss function, the scheme combines the total contrast loss function and the negative log-likelihood loss function to achieve multi-dimensional optimization of the model. The total contrast loss function includes the group contrast loss function, the sequence contrast loss function and the sequence-group contrast loss function, which can comprehensively evaluate the performance of the model on various contrast tasks. The negative log-likelihood loss function ensures that the probability distribution of the model when generating recommendation results is consistent with the actual data distribution. Finally, the online group recommendation results obtained based on the multi-scale contrastive learning dual-tower optimization model provide a new solution for the field of online group recommendation.
[0155] Additionally, in other embodiments, a performance evaluation phase of the model may be set after generating the online group recommendation results to evaluate the recommendation quality. The recommendation method is continuously improved by evaluating the online group recommendation results to further improve the recommendation quality and meet user needs. The evaluation indicators used mainly include accuracy, recall, F1 value, and normalized discounted cumulative gain (NDCG). Among them, accuracy, recall, and F1 value are used to evaluate the accuracy of the recommendation result classification, and NDCG is used to evaluate the accuracy of the recommendation result ranking.
[0156] See also Figure 3 , which is a schematic diagram of the structure of an online group recommendation system based on a multi-scale contrastive learning twin-tower model proposed in the second embodiment of the present application, and the system includes:
[0157] A data acquisition module 10 is used to acquire online group related information, pre-process the online group related information, and obtain a user group sequence, a user initial representation, an event initial representation, and a neighbor set of users and events;
[0158] The model building module 20 is used to build a multi-scale contrastive learning twin-tower model, and the multi-scale contrastive learning twin-tower model includes:
[0159] A sequence coding network unit 201, wherein the sequence coding network unit 201 comprises:
[0160] The group embedding coding layer 2011 is used to obtain a group embedding representation according to the user's group sequence;
[0161] The sequence initial coding layer 2012 is used to obtain an initial group coding sequence according to the group embedding representation;
[0162] A similar user coding layer 2013, used to obtain a group coding sequence according to an initial group coding sequence;
[0163] A group coding network unit 202, wherein the group coding network unit 202 comprises:
[0164] The opinion fusion layer 221 is used to obtain the final representation of each node according to the initial representation of the user, the initial representation of the event, and the neighbor sets of the user and the event;
[0165] The feature aggregation layer 2022 is used to obtain the final representation of the group according to the final representation of each node;
[0166] The contrastive learning network unit 203 includes:
[0167] A group-group comparison layer 2031 is used to construct a group comparison loss function;
[0168] A sequence-sequence comparison layer 2032, used to construct a sequence comparison loss function;
[0169] A sequence-group comparison layer 2033, used to construct a sequence-group comparison loss function;
[0170] Constructing a training function module 30, for constructing an optimization loss function to train the multi-scale contrastive learning twin-tower model, to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function, and the sequence-group contrast loss function;
[0171] The recommendation prediction module 40 is used to obtain online group recommendation results based on the multi-scale contrastive learning dual-tower optimization model.
[0172] On the other hand, the present application further proposes a computer device, which includes a memory, a processor, and a processing program stored in the memory and executable on the processor, wherein the processing program implements the above-mentioned online group recommendation method when executed by the processor.
[0173] On the other hand, the present application further proposes a storage medium, on which a processing program is stored, and when the processing program is executed by a processor, the online group recommendation method is executed.
[0174] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0175] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0176] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An online group recommendation method based on a multi-scale contrastive learning twin-tower model, characterized in that: The method comprises: Obtaining relevant information of online group recommendation, preprocessing the relevant information, and obtaining a user group sequence, a user initial representation, an event initial representation, and a neighbor set of the user and the event; Construct a multi-scale contrastive learning dual-tower model, including: The left tower of the multi-scale contrastive learning dual-tower model is constructed, including a sequence coding network, wherein the sequence coding network includes a group embedding coding layer, a sequence initial coding layer and a similar user coding layer, wherein the group embedding coding layer is used to obtain a group embedding representation according to the user's group sequence, the sequence initial coding layer is used to obtain an initial group coding sequence according to the group embedding representation, and the similar user coding layer is used to obtain a group coding sequence according to the initial group coding sequence, wherein a multi-head attention mechanism of similar user perception is adopted in the similar user coding layer to obtain User preferences at the Lth Transformer layer ; The initial group coding sequence After concatenation, the group coding sequence is obtained through the fully connected layer. ; The right tower of the multi-scale contrastive learning dual-tower model is constructed, including a group coding network, wherein the group coding network includes an opinion fusion layer and a feature aggregation layer, wherein the opinion fusion layer is used to obtain the final representation of each node according to the initial representation of the user, the initial representation of the event, and the neighbor set of the user and the event, and the feature aggregation layer is used to obtain the final representation of the group according to the final representation of each node, wherein based on the node The final representation , using a one-level multi-head attention mechanism to aggregate user features into event features ; Then use the secondary multi-head attention mechanism to Aggregation to obtain the final representation of the group ; Constructing a contrastive learning network of a multi-scale contrastive learning dual-tower model, including a group-group contrast layer, a sequence-sequence contrast layer, and a sequence-group contrast layer, wherein the group-group contrast layer is used to construct a group contrast loss function, the sequence-sequence contrast layer is used to construct a sequence contrast loss function, and the sequence-group contrast layer is used to construct a sequence-group contrast loss function; Constructing an optimization loss function to train the multi-scale contrastive learning twin-tower model to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function, and the sequence-group contrast loss function; The online group recommendation result is obtained based on the multi-scale contrastive learning dual-tower optimization model.
2. The online group recommendation method according to claim 1, characterized in that: The method also includes formally defining an online group recommendation method: Defining online networks ,in and Respectively represent the user node set and the online group node set, represents the online edge set; Defining offline networks ,in and Represent the user node set and offline event node set respectively, represents the offline edge set; Defining Users Online group sequence , Indicates user In time step Join online groups, Indicates the length of the sequence; Defining online networks , offline network and users Online group sequence As input to the multi-scale contrastive learning twin-tower model; definition The online groups with the highest prediction scores are output as recommendation results; Define the objective function ,in Represents the calculation of user pairs in groups The preference score of Indicates user In time step Online groups to join.
3. The online group recommendation method according to claim 2, characterized in that: The step of obtaining a group embedding representation according to the group sequence of the user by the group embedding coding layer comprises: Embedding learnable positions Injected into the user's group sequence Groups in In the above example, we get the sequence representation of each position. ; Represent the sequence at each position Stacked into a matrix , That is the group embedding representation.
4. The online group recommendation method according to claim 3, characterized in that: The step of obtaining an initial group coding sequence according to the group embedding representation by the sequence initial coding layer includes: Use a Transformer layer in the initial encoding layer of the sequence and calculate the group embedding representation for each position in each layer of the Transformer layer ; Embedding the group representation at each position Stacked into a matrix , , represents the depth of the Transformer layer, This is the initial group coding sequence.
5. The online group recommendation method according to claim 2, characterized in that: The opinion fusion layer is used to obtain the final representation of each node according to the user initial representation, the event initial representation and the neighbor set of the user and the event, including: In the opinion fusion layer, the GAT layer is used to embed the user initial representation, event initial representation, and the neighbor set of users and events into the GAT layer to obtain the node With adjacent nodes Similarity ; Based on the similarity , use the multi-head attention mechanism to represent the splicing and get the node The final representation .
6. The online group recommendation method according to claim 2, characterized in that: The optimization loss function ; in is a hyperparameter used to control the strength of the contrastive loss, represents the negative log-likelihood loss function, represents the total contrast loss function; ,in, represents the group contrast loss function, represents the sequence contrast loss function, represents the sequence-group contrast loss function; ,in, Indicates the time step The truth value of Indicates that the sequence A subsequence of groups, Before A collection of groups.
7. An online group recommendation system based on a multi-scale contrastive learning twin-tower model, characterized in that: The system comprises: A data acquisition module is used to acquire relevant information of online group recommendation, pre-process the relevant information, and obtain the user's group sequence, user initial representation, event initial representation, and neighbor sets of users and events; A model building module is used to build a multi-scale contrastive learning twin-tower model, wherein the multi-scale contrastive learning twin-tower model includes: A sequence coding network unit, the sequence coding network unit comprising: The group embedding encoding layer is used to obtain the group embedding representation according to the user's group sequence; The sequence initial coding layer is used to obtain the initial group coding sequence according to the group embedding representation; The similar user coding layer is used to obtain the group coding sequence according to the initial group coding sequence. In the similar user coding layer, a multi-head attention mechanism of similar user perception is adopted to obtain the group coding sequence in the time step. User preferences at the Lth Transformer layer ; The initial group coding sequence After concatenation, the group coding sequence is obtained through the fully connected layer. ; A group coding network unit, the group coding network unit comprising: The opinion fusion layer is used to obtain the final representation of each node based on the initial representation of the user, the initial representation of the event, and the neighbor sets of the user and the event; The feature aggregation layer is used to obtain the final representation of the group based on the final representation of each node. The final representation , using a one-level multi-head attention mechanism to aggregate user features into event features ; Then use the secondary multi-head attention mechanism to Aggregation to obtain the final representation of the group ; A contrastive learning network unit, the contrastive learning network unit comprising: Group-group comparison layer, used to construct the group comparison loss function; Sequence-sequence comparison layer, used to construct the sequence comparison loss function; The sequence-group contrast layer is used to construct the sequence-group contrast loss function; Constructing a training function module, which is used to construct an optimization loss function to train the multi-scale contrastive learning twin-tower model to obtain a multi-scale contrastive learning twin-tower optimization model, wherein the optimization loss function includes a total contrast loss function and a negative log-likelihood loss function, and the total contrast loss function includes the group contrast loss function, the sequence contrast loss function, and the sequence-group contrast loss function; The recommendation prediction module is used to obtain online group recommendation results based on the multi-scale contrastive learning dual-tower optimization model.
8. A computer device, characterized in that: The computer device comprises a memory, a processor, and a processing program stored in the memory and executable on the processor. When the processing program is executed by the processor, the online group recommendation method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Double-tower social contact recommendation method based on federal contrast learning
CN116049570A
Commodity recommendation method, device and equipment and storage medium
CN117635238A