Text-based recommendation method and device, equipment and storage medium
Through text-based recommendation methods, the user's semantics and behavioral intentions are obtained using interaction sequences and encoders, which solves the problem of poor recommendation results when there is less user interaction data, and achieves more accurate user interest learning and recommendation results.
Patent Information
- Application Number
- CN202510301917.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-03-14
AI Technical Summary
The existing recommendation model is difficult to accurately learn user interest characteristics when there is little user interaction data, resulting in poor recommendation results.
Using a text-based recommendation method, by obtaining the user's target domain interaction sequence, the text encoder and the semantic intention encoder are used to obtain the user's semantic intention, and the user's behavioral intention is obtained through the item encoder and the behavioral intention encoder. Combining the textual semantic representation matrix of candidate items and the user's intention, recommend items are selected from candidate items.
Even when the user interaction data is small, the encoder trained through the cross-domain cross-attention mechanism can fully learn the user's semantic intentions and improve the recommendation effect of the recommendation model.
Smart Images

Figure CN119807541A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of item recommendation, and in particular to a text-based recommendation method, device, equipment and storage medium. Background Art
[0002] Recommendation systems are a type of automated tool widely used on various online platforms. They aim to help users discover products or content that match their preferences by modeling their interest intentions, thereby effectively alleviating the problem of information overload. Sequential recommendation algorithms take into account a series of interactions between users and items to capture the changing patterns of user preferences over time and predict the products or content that users are most likely to be interested in in the future. However, most existing sequential recommendation models often rely on rich user interaction data to learn accurate interest representations. When user interaction records are insufficient, such models may find it difficult to fully capture user interest characteristics, resulting in poor recommendation results. In other words, when there is less user interaction record data, using less interaction record data makes it difficult for the recommendation model to accurately learn the user's interests and hobbies.
[0003] In summary, the existing recommendation models reduce the recommendation effect when users have less interaction data.
[0004] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention
[0005] To solve the above technical problems, the present invention provides a text-based recommendation method, apparatus, device and storage medium, which solves the problem that the existing recommendation model reduces the recommendation effect when the user has less interactive data.
[0006] To achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present invention provides a text-based recommendation method, comprising: Obtain a target domain interaction sequence of a user including interactive items, apply a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; apply a semantic intent encoder to the target text semantic representation matrix to obtain a semantic intent of the user; Applying an item encoder to the target domain interaction sequence to obtain an item encoding matrix; applying a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention, wherein the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process, and the cross-attention mechanism is used to enable the semantic intention encoder to perform cross-learning in the source domain and the target domain, so that the semantic intention encoder becomes a cross-domain encoder; Acquire candidate items and item numbers of the candidate items, generate a text semantic representation matrix of the candidate items, and screen recommended items from the candidate items to be recommended to the user based on the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
[0007] In one implementation, selecting recommended items for the user from the candidate items based on the text semantic representation matrix and item number of the candidate items and the semantic intention and behavioral intention of the user includes: Generating an item vector of the candidate item according to the text semantic representation matrix and the item number of the candidate item; Obtaining a user preference vector according to the semantic intention and the behavioral intention, wherein the preference vector is used to represent the user's preference for each of the interactive items; According to the preference vector of the user and the item vector of each of the candidate items, recommended items are screened out from the candidate items to be recommended to the user.
[0008] In one implementation, the semantic intent encoder, the text encoder, the object encoder, and the behavior intent encoder are trained in a joint manner, wherein the joint training manner includes: Setting a text auxiliary encoder and an item auxiliary encoder, wherein the text auxiliary encoder and the item auxiliary encoder are two encoders set for assisting in training the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder; Obtaining the interaction sample sequence of the same user in the source domain and the interaction sample sequence in the target domain; Applying a text-assisted encoder and an item-assisted encoder to the interaction sample sequence of the source domain respectively to obtain a source sample text semantic representation matrix and a source sample item encoding matrix; Applying the text encoder and the object encoder to the interaction sample sequence of the target domain respectively to obtain a target sample text semantic representation matrix and a target sample object encoding matrix; By means of the cross attention mechanism, the inter-domain preference as a positive sample is obtained according to the target sample text semantic representation matrix, the source sample text semantic representation matrix and the source sample item coding matrix; Obtaining the target sample semantic intent through the semantic intent encoder according to the target sample text semantic representation matrix, a neighborhood shared attention matrix composed of the source sample text semantic representation matrix and the target sample text semantic representation matrix; Obtaining the target sample behavior intention according to the target sample item coding matrix through the behavior intention encoder; According to the semantic intention of the target sample and the behavioral intention of the target sample, obtaining an in-domain preference as a positive sample; Obtain the inter-domain preferences of other users and use them as the inter-domain preferences of negative samples; The contrast loss is obtained according to the inter-domain preference as the positive sample, the intra-domain preference as the positive sample, and the inter-domain preference as the negative sample; Based on the contrast loss, a total loss is constructed, and iterative training is performed based on the total loss.
[0009] In one implementation, constructing a total loss based on the contrast loss includes: Aggregating the inter-domain preference and intra-domain preference of the same user to obtain the final sample preference of the same user; Obtaining a cross entropy loss according to the text semantic vector and the item number of the candidate item and the final preference of the sample; A total loss is constructed based on the contrast loss and the cross entropy loss.
[0010] In one implementation, the cross-attention mechanism is used to obtain the inter-domain preference as a positive sample according to the target sample text semantic representation matrix, the source sample text semantic representation matrix, and the source sample item coding matrix, including: By using the target sample text semantic representation matrix as the query vector of the cross-attention mechanism, the source sample text semantic representation matrix as the key vector of the cross-attention mechanism, and the source sample item coding matrix as the value vector of the cross-attention mechanism, the inter-domain preference as a positive sample is obtained.
[0011] In one implementation, the semantic intent encoder obtains the target sample semantic intent according to the target sample text semantic representation matrix, a neighborhood shared attention matrix composed of the source sample text semantic representation matrix and the target sample text semantic representation matrix, including: The target sample text semantic representation matrix is used as the query vector and key vector of the attention mechanism inside the semantic intent encoder to obtain the target domain attention matrix; Merging the neighborhood shared attention matrix and the target domain attention matrix to obtain an attention matrix of shared semantic association; The target sample text semantic representation matrix is used as a value vector and the target sample semantic intent is obtained according to the attention matrix of the shared semantic association.
[0012] In one implementation, the semantic intention and the behavioral intention of the user respectively represent the semantic intention and the behavioral intention reflected by the user's last interaction.
[0013] In a second aspect, an embodiment of the present invention further provides a text-based recommendation device, wherein the device includes the following components: A semantic intention prediction module is used to obtain a target domain interaction sequence of a user including interactive items, apply a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; apply a semantic intention encoder to the target text semantic representation matrix to obtain the user's semantic intention; A behavior intention prediction module is used to apply an item encoder to the target domain interaction sequence to obtain an item encoding matrix; apply a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention; the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process. The cross-attention mechanism is used to enable the semantic intention encoder to cross-learn in the source domain and the target domain, thereby making the semantic intention encoder a cross-domain encoder; The recommendation module is used to obtain candidate items and item numbers of the candidate items, and generate a text semantic representation matrix of the candidate items, and screen recommended items from the candidate items to be recommended to the user based on the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
[0014] In a third aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device includes a memory, a processor, and a text-based recommendation program stored in the memory and executable on the processor, and when the processor executes the text-based recommendation program, the steps of the above-mentioned text-based recommendation method are implemented.
[0015] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a text-based recommendation program is stored. When the text-based recommendation program is executed by a processor, the steps of the above-mentioned text-based recommendation method are implemented.
[0016] Beneficial effects: The present invention applies a text encoder and a semantic intent encoder to the interaction sequence generated by the user in the target domain to obtain the user's semantic intent; and then applies an item encoder and a behavioral intent encoder to the interaction sequence to obtain the user's behavioral intent. Finally, based on the user's semantic intent and behavioral intention as well as the item number and text semantics of the candidate items, recommended items are screened out from the candidate items and recommended to the user. Since the present invention introduces a cross-attention mechanism for auxiliary training when training the above four encoders, the cross-attention mechanism enables the semantic intent encoder of the target domain to learn based on both the interaction sequence of the target domain and the interaction sequence of the source domain. Therefore, even if the number of interaction sequences in the target domain is insufficient, since the semantic intent encoder has also been learned in the source domain, the semantic intent encoder can fully learn the user's semantic intent, thereby ultimately improving the recommendation effect of the recommendation model based on the semantic intent encoder of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is the overall flow chart of the present invention; Figure 2 is a prediction flow chart in an embodiment of the present invention; Figure 3 is a training flow chart in an embodiment of the present invention; Figure 4 Schematic diagram of positive and negative sample pairs in an embodiment of the present invention; Figure 5 Schematic diagram of the influence of contrast loss weight in an embodiment of the present invention; Figure 6 A structural diagram of a text-based recommendation device provided by the present invention; Figure 7 This is a block diagram of the internal structure principle of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following is a clear and complete description of the technical solution of the present invention in combination with the embodiments and the accompanying drawings. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] Research has found that recommendation systems are a type of automated tool widely used in various online platforms. They aim to help users find products or content that meet their preferences by modeling user interest intentions, thereby effectively alleviating the problem of information overload. The sequential recommendation algorithm takes into account a series of interactions between users and items to capture the changing patterns of user preferences over time and predict the products or content that users are most likely to be interested in in the future. However, most existing sequential recommendation models often rely on rich user interaction data to learn accurate interest representations. When user interaction records are insufficient, such models may find it difficult to fully capture user interest characteristics, resulting in poor recommendation results. That is, when there is less user interaction record data, using less interaction record data makes it difficult for the recommendation model to accurately learn the user's interests and hobbies.
[0020] To solve the above technical problems, the present invention provides a text-based recommendation method, apparatus, device and storage medium, which solves the problem that the existing recommendation model reduces the recommendation effect when the user has less interactive data.
[0021] The text-based recommendation method of this embodiment can be applied to a terminal device, which can be a terminal product with a data processing function, such as a computer. Figure 1 As shown in , the text-based recommendation method specifically includes the following steps: S100, obtaining a target domain interaction sequence of a user including interactive objects, applying a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; applying a semantic intention encoder to the target text semantic representation matrix to obtain a semantic intention of the user; S200, applying an item encoder to the target domain interaction sequence to obtain an item encoding matrix; applying a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention, wherein the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for assisting training is introduced during the training process, and the cross-attention mechanism is used to enable the semantic intention encoder to perform cross-learning in the source domain and the target domain, thereby making the semantic intention encoder a cross-domain encoder; S300, obtaining candidate items and item numbers of the candidate items, and generating a text semantic representation matrix of the candidate items, and filtering recommended items to be recommended to the user from the candidate items according to the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
[0022] The above recommendation method of the present invention can be used to recommend movies to users on a mobile phone. The specific process is as follows: First, the recommendation model is trained. Figure 2 The text encoder located on the text encoding layer, the item encoder located on the item encoding layer, the cross-domain semantic intent encoder, the target domain behavioral intention encoder, two mapping layers, the text encoding layer and the item encoder layer located on the candidate item side, among which the text encoder located on the text encoding layer, the item encoder located on the item encoding layer, the cross-domain semantic intent encoder, and the target domain behavioral intention encoder are the encoders that need to be trained.
[0023] When training the recommendation model, Figure 3 As shown in the figure, it is necessary to introduce a text-assisted encoder (located on the text encoding layer), an item-assisted encoder (located on the item encoding layer), and a neighborhood-shared cross-attention mechanism for processing source domain interaction sequences. That is, when training the text encoder, item encoder, semantic intent encoder, and behavioral intent encoder in the target domain, it is necessary to jointly train the text-assisted encoder, item-assisted encoder, and cross-attention mechanism.
[0024] During training, the information about the movies (movies are objects) that the user has watched is arranged in the order of the time when the movies were watched, forming a target domain interaction sequence (the interaction sequence is the interaction sample sequence of the target domain); the books related to the movies that the user has read are also arranged in the order of the reading time, forming a source domain interaction sequence (the interaction sequence is the interaction sample sequence of the source domain, Figure 3 In , , , is each interaction information in the source domain interaction sequence). Figure 3 As shown in Figure 2, the target domain interaction sequence is input into the text encoder and the object encoder respectively, and the source domain interaction sequence is also input into the text encoder and the object encoder respectively. Figure 3 After processing, the final user preferences, semantic intentions, and behavioral intentions are obtained, and then the candidate items that the user may prefer are predicted based on the final user preferences. Finally, the final loss function is obtained based on whether the candidate items that may be preferred are the items that the user actually likes, semantic intentions, and behavioral intentions. According to the final loss function, backpropagation is performed to adjust the text encoder, item encoder, semantic intent encoder, behavioral intention encoder, train text auxiliary encoder, item auxiliary encoder, and cross attention mechanism until the training is completed.
[0025] After training, when you need to recommend a movie to a user, you only need to form a target domain interaction sequence with the relevant information of the movie the user has watched, and then input the target domain interaction sequence into Figure 2 The recommendation model can get the movies recommended to the user. Figure 2 In , , , Represents each interaction information in the target domain interaction sequence.
[0026] Embodiment 1, this embodiment provides a training method for jointly training a semantic intent encoder, a text encoder, an object encoder, and a behavior intent encoder, including the following specific steps S01 to S015: S01, setting a text-assisted encoder and an item-assisted encoder, wherein the text-assisted encoder and the item-assisted encoder are two encoders set to assist in training the semantic intent encoder, the text encoder, the item encoder, and the behavioral intent encoder.
[0027] The text auxiliary encoder is located in Figure 3 The encoder on the text encoding layer above, the item auxiliary encoder is located at Figure 3 The encoder on the item encoding layer above. Both the text-assisted encoder and the text encoder use the pre-trained language model BERT, and the semantic intent encoder uses the causal Transformer model (i.e., a deep learning model based on the attention mechanism).
[0028] S02, obtaining an interaction sample sequence of the same user in a source domain and an interaction sample sequence in a target domain.
[0029] During training, since the user's interaction sequences in the target domain are insufficient, the user's interaction sequences in the source domain are used together as the training data set to make up for the deficiency of insufficient interaction sequences in the target domain and provide sufficient data sets for training.
[0030] S03, applying a text-assisted encoder and an item-assisted encoder to the interactive sample sequence in the source domain respectively to obtain a source sample text semantic representation matrix And the source sample item coding matrix .
[0031]
[0032]
[0033] ; ; ; In the formula, Represents the source domain, 1, 2, and n are the item numbers. Represents the original semantics corresponding to the target sample text. The text information includes comment information and meta information. Meta information is used to represent the category of the item and the information describing the item. Comment information is used to represent the user's evaluation of the item. represents the location of the item (the location is used to characterize the interaction time of the item), For the source field The sample text in the sample source field (the sample text included in the interactive sample sequence in the sample source field) records the items The corresponding meta information text, Represents meta information, For the source field The sample text in the sample source field (the sample text included in the interactive sample sequence in the sample source field) records the items The corresponding comment information text, Indicates user For items (thing That is, the interaction sequence number is The semantic representation vector of the comments of the items) represents the dimension of the output vector, For all users The set composed of Indicates items The meta-information semantic representation vector of Represents the item ID number, represents the pre-trained language model, projection Refers to the linear mapping layer, which is mainly implemented by a simple fully connected layer. Its purpose is to linearly change the semantic representation matrix. Represents standardized processing, Represents averaging.
[0034] S04, applying the text encoder and the object encoder to the interaction sample sequence of the target domain respectively to obtain a target sample text semantic representation matrix And the target sample item coding matrix ; The calculation method and The calculation method is the same as that of The sample text of can be replaced with the sample text of the target domain y. Similarly, The calculation method and The calculation method is the same as that of the source domain The sample text of is replaced with the sample text of the target domain y.
[0035] S05, such as Figure 3 As shown, by using the target sample text semantic representation matrix As the query vector Q of the cross attention mechanism, the source sample text semantic representation matrix As the key vector K of the cross attention mechanism, the source sample item encoding matrix As the value vector V of the cross-attention mechanism, we get the inter-domain preference as a positive sample .
[0036] Since the same user has high-level semantic connections in different fields, this information reflects the user's long-term stable interest trends and can assist in user representation modeling in cross-domain recommendations. Therefore, a domain-shared cross-attention mechanism can be designed. The core idea is to calculate the semantic connection between the text representations of the source domain and the target domain in the attention graph, and combine the user's behavioral preferences in the source domain to construct a cross-domain preference representation.
[0037] ; is the preference vector output by the cross attention mechanism, The (No. last) preference After a layer of perceptual mapping based on a fully connected layer, the inter-domain preference can be obtained .
[0038] ; In the formula, , represents the encoder, where the encoder is used to encode the sequence. (i.e. Feed-forwardNetwor) is a feed-forward neural network, T is the transpose of the matrix, represents normalization processing, represents the potential dimension of the vector, represents the mapping based on the fully connected layer, is a learnable weight matrix, domain-shared attention matrix The shared semantic associations between the source and target domains are learned.
[0039] S06: transform the target sample text semantic representation matrix As the query vector of the attention mechanism inside the semantic intent encoder and key vector , get the target domain attention matrix .
[0040] ; in, is a learnable weight matrix.
[0041] S07, merging the neighborhood shared attention matrix and the target domain attention matrix to obtain a shared semantically associated attention matrix : ; In the formula, is a learnable mapping matrix.
[0042] In this embodiment, S06 and S07 use causal Transformer as an independent encoder (Transformer is a semantic intent encoder), and introduce a reweighted attention graph mechanism based on the semantic alignment operator (SAO). By adaptively fusing the semantic attention graph of the target domain and the semantic attention graph of shared semantic associations, the semantic intent learning of the target domain is enhanced, thereby more accurately capturing the user's cross-domain interest preferences.
[0043] S08, such as Figure 3 As shown, by using the target sample text semantic representation matrix As a value vector, the attention matrix based on shared semantic associations , get the semantic intention of the target sample .
[0044] The vector output by the cross-domain semantic intent encoder The semantic intention of the last n (i.e., the nth) in is defined by the following formula : ; represents the encoder, where the encoder is a cross-domain semantic intent encoder. represents a feed-forward neural network, is a learnable weight matrix.
[0045] When the target domain is the movie domain, the semantic intent is the user's preference for movie themes, that is, the semantic intent represents the movie themes preferred by the user.
[0046] S09, such as Figure 3 As shown, the target sample behavior intention is obtained through the behavior intention encoder according to the target sample item coding matrix. .
[0047] The vector output by the behavioral intention encoder for the target domain The last behavioral intention in is defined by the following formula : ; Represents an encoder, here a behavioral intention encoder.
[0048] In this embodiment, considering that the user's behavioral intention and semantic intention in the target domain are similar, in order to promote the alignment of intent representation, this embodiment uses a Transformer that shares weights with the cross-domain intent encoder to model the target domain object ID representation matrix , and obtain the user's preference vector in the target field .
[0049] When the target domain is the movie domain, the behavioral intention represents the actor, director, or screenwriter of the movie that the user prefers.
[0050] S010, obtaining the in-domain preference as a positive sample according to the semantic intention of the target sample and the behavioral intention of the target sample : ; In the formula, represent Figure 3 The merging of the coarse-grained cross-domain semantic intent representation and fine-grained behavioral intention representation , get the domain preference .
[0051] S011, obtain the inter-domain preferences of other users and use them as the inter-domain preferences of negative samples .
[0052] Through steps S02, S03, S04, and S05, the same user (the user is Figure 4 The shared user in the source domain has the intra-domain preference between the source domain and the target domain, and the inter-domain preference corresponding to the user is As positive samples. Replace the user in steps S02, S03, S04, and S05 with another user (the other user is another user), and use the same processing method as steps S02, S03, S04, and S05 on the interaction sequence of the other user in the source domain and the interaction in the target domain, and you can get the inter-domain preference as a negative sample. .like Figure 4 Inter-domain preference shown and domain preference This constitutes a positive sample pair, while other users’ inter-domain preferences This constitutes the negative sample set.
[0053] S012, based on the inter-domain preference as a positive sample , as the in-domain preference of positive samples , as the inter-domain preference of negative samples , and get the contrast loss .
[0054] Although users have different distributions of behavior patterns in the source domain and the target domain, their long-term preferences are consistent. Therefore, it is necessary to design effective supervision signals to align user representations in different domains. This embodiment proposes a semantic-behavioral hybrid enhanced contrastive learning mechanism. Considering the same user's intra-domain preferences and inter-domain preference As positive sample pairs, the inter-domain preferences of other users As negative samples. This contrastive learning maximizes the preference representations of overlapping users across domains and within domains, and minimizes the preference representations of other users across domains. Since each vector representation in the positive sample pair and the negative sample pair aggregates semantic intent and behavioral intent, it can fully promote cross-domain knowledge transfer. The calculation formula is as follows: ; In the formula, (·) represents the sigmoid function (the sigmoid function is a binarization function), (·) represents the dot product used to calculate the similarity of the vectors. Represents the first time steps, Represents the total number of time steps.
[0055] S013, aggregating the inter-domain preference and intra-domain preference of the same user , get the final preference of the sample of the same user In this embodiment, the inter-domain preference of the same user is used as the inter-domain preference of the positive sample .
[0056] ; In the training phase, in order to promote cross-domain knowledge transfer, this embodiment adopts the aggregation preference To calculate the loss, the model can make full use of the comprehensive information of the source and target domains and optimize the alignment of cross-domain user representations.
[0057] S014, obtaining a cross entropy loss according to the text semantic vector and item number of the candidate item and the final preference of the sample : ; ; ; Target Area Candidate items within The text semantic vector of the item number Target Area Candidate items within The ID encoding vector. represents negative samples sampled from the target domain. (·)express Activation function, Target Area The set of candidate items, Target area A collection of user behavior sequences. Represents any user , represents the set of all users, Represents the first time steps (a total of time steps).
[0058] S015, according to the contrast loss and the cross entropy loss , construct the total loss , and iterative training is performed based on the total loss.
[0059] ; in is a hyperparameter that controls the semantic-behavioral hybrid enhancement contrast loss.
[0060] Embodiment 2: This embodiment limits each encoder in Embodiment 1 to a sequence encoder based on Transformer , where the encoding process of the sequence encoder is as follows: Given an input representation matrix , first converts it into a query in the attention mechanism through three linear projection layers ,key Sum . Among them, the attention map can be defined as:
[0061] in, is a scaling factor, is the potential vector dimension, is a learnable weight matrix. Finally, the output of attention can be defined as: ; in, is the potential representation of the output, is a learnable weight matrix. The potential representation of the attention output is passed through a point-by-point feed-forward network (FNN), and the formula is as follows:
[0062] in, is a learnable weight matrix, is a learnable bias vector, is the final output of the encoder.
[0063] Embodiment 3: After training is completed, based on Figure 2 A recommended item can be selected from the candidate items and recommended to the user, including the following specific steps: S301, generating an item vector of the candidate item according to the text semantic representation matrix and item number of the candidate item; S302, obtaining a user preference vector according to the semantic intention and the behavioral intention, wherein the preference vector is used to represent the user's preference for each of the interactive items; S303: Filter recommended items to be recommended to the user from the candidate items according to the preference vector of the user and the item vector of each candidate item.
[0064] The effectiveness of the recommended method of the present invention is demonstrated by experiments below: The present invention uses three datasets from shopping websites: Movie, CD, and Book. The above datasets contain overlapping user interactions in different fields and are suitable for cross-domain sequence recommendation research.
[0065] The present invention performs the following data preprocessing operations on the above three datasets: i) only retain users and items with at least five interactions; ii) delete duplicate users and delete duplicate items; iii) sort the interactions of each user in chronological order; iv) only retain users who have interactions in all three areas.
[0066] In order to evaluate the recommendation performance of the present invention, the present invention adopts two common indicators, including the hit rate indicator (hit rate indicator, namely HR@K) and the normalized discounted cumulative gain indicator (normalized discounted cumulative gain indicator, namely NDCG@K), K {5,10}, K is the number of items recommended to the user. The recommendation algorithm generally selects K items that the user may like most from the entire set of candidate items and recommends them to the user.
[0067] The present invention uses the leave-one-out method for evaluation, that is, the last item in each sequence is used as the test set, the second-to-last item is used as the validation set, and the previous items are used as the training set. In order to reduce the computational complexity, the present invention adopts a sampling-based evaluation strategy, that is, 100 negative samples and 1 true positive sample are randomly selected from the entire candidate item set for evaluation according to the popularity of the item.
[0068] In order to verify the effectiveness of the recommendation method proposed in the present invention, the present invention compares four types of baseline models: a sequence recommendation model based on item ID (item ID is item number), a sequence recommendation model based on additional information enhancement, a sequence recommendation model based on item ID and text enhancement, and a cross-domain sequence recommendation model.
[0069] Among them, the sequence recommendation model based on item ID includes the following recommendation methods: GRU4Rec: A recurrent neural network based sequence recommendation method that uses gated neural networks to model user preferences.
[0070] SASRec: A causal Transformer-based sequential recommendation method that uses Transformer to capture user dynamic preferences.
[0071] The sequence recommendation model based on additional information enhancement includes the following recommendation methods: DIF: A decoupled attention matrix based sequence recommendation method for enhanced fusion of additional information (category information).
[0072] MSSR: A sequence recommendation model enhanced with additional information adaptive aggregation via multi-sequence attention.
[0073] The sequential recommendation model based on item ID and text enhancement includes the following recommendation methods: DIF++: An extended version of DIF that integrates item review information and meta-information as additional information.
[0074] SASRec++: An extended version of SASRec that uses two identical attention modules to model item ID sequences and text sequences.
[0075] CCA: A sequential recommendation model that aggregates review information using cascaded criss-cross attention.
[0076] The cross-domain sequence recommendation model includes the following recommendation methods: CD-SASRec: A Transformer-based cross-domain sequence recommendation model with cross-domain knowledge fusion in the attention mechanism.
[0077] MGCL: A cross-domain sequence method based on multi-view graph neural network and cross-domain knowledge transfer using multi-view contrastive learning.
[0078] UniSRec: A cross-domain sequence recommendation method based on text semantic comparison, which learns common semantic representations from text information in multiple domains and fine-tunes the item ID representation in the downstream domain for cross-domain recommendation.
[0079] VQRec: A semantic representation transfer recommendation method based on vector quantization. This method uses a cross-domain fine-tuning strategy based on a differentiable permutation network in the downstream domain to enhance the adaptability of semantic transfer to the recommendation space.
[0080] The experimental results are shown in Table 1, where the best experimental results are marked in bold black (the experimental results marked in bold black are the data in the row CT2CSR in Table 1); the suboptimal experimental results are marked with underlines (the experimental results marked with underlines are the data in the row UniSRec(T+ID) in Table 1). Among them, N@K represents NDCG@K, H@K represents Hit@K, and N@K includes N@5 and N@10 in Table 1. N@5 is the normalized cumulative loss gain with a parameter of 5, and N@10 is the normalized cumulative loss gain with a parameter of 10; H@5 is the hit rate indicator with a parameter of 5, and H@10 is the hit rate indicator with a parameter of 10.
[0081] In Table 1, the present invention has the following conclusions: (i) In single-action sequence recommendation, SASRec outperforms GRU4Rec, indicating that the attention-based method is better than the recurrent neural network in capturing user dynamic preferences. Compared with SASRec, DIF and MSSR perform better, indicating that the method based on additional information enhancement effectively enhances user representation. (ii) SASRec++ and CCA are both better than SASRec, indicating that text information, as an effective auxiliary signal, can enhance the learning of user preferences. DIF++ performs better than SASRec but worse than SASRec++, indicating that the fusion method of this method may not be suitable for text semantic representation. (iii) The performance of text-based cross-domain recommendation methods (e.g., VQRec(T), where T means text and UniSRec(T)) is better than that of item ID-based cross-domain recommendation methods (e.g., MGCL, CD-SASRec), which shows that using text information as a cross-domain bridge can effectively enhance the effect of cross-domain recommendation. The performance of UniSRec(T+ID) is second only to the CT2CSR model proposed in this method, where T+ID means text plus ID. (iv) The present invention (the present invention is CT2CSR in Table 1, where CT2CSR is cross-domain sequence recommendation based on contrastive text enhanced attention mechanism) surpasses all baseline methods on the three datasets, and achieves 5.51%, 5.86%, 6.11% and 6.68% improvements in N@5, H@5, N@10 and H@10, respectively, compared with the best performing baseline method.
[0082] In order to verify the effectiveness of each component in the CT2CSR model proposed in this paper, ablation experiments were conducted on three datasets. Each ablation component is as follows: (1) w / o TCA, removing the domain-shared cross-attention mechanism and also removing the cross-domain user preference in the prediction layer.
[0083] (2) w / o SPO: The semantic alignment operator in the cross-domain semantic intent encoder is removed and only the attention matrix of the target domain text representation is considered.
[0084] (3) w / o BIE: remove the behavioral intention encoder in the target domain and remove the ID representation of candidate items in the prediction layer.
[0085] (4) w / o SIE: Remove the cross-domain semantic intent encoder and remove the semantic representation of candidate items at the prediction layer.
[0086] (5) w / o SBCL: removing the semantic-behavioral dual-view contrastive learning task.
[0087] The results of the ablation experiment are reported in Table 2. The following conclusions are drawn from the present invention: (1) Removing any component in CT2CSR leads to a decrease in model performance, which proves the effectiveness of each module in the model; (2) Removing the cross-domain semantic intent encoder leads to the largest performance decrease, which indicates that the cross-domain semantic intent based on text sequence effectively improves user representation learning; (3) Removing the target domain behavior intent encoding leads to the second largest performance decrease, which indicates that the user's fine-grained interactive behavior intention is the key to capturing user preferences; (4) Removing the domain-shared cross-attention mechanism reduces model performance, which indicates that cross-domain semantic connections have a positive impact on cross-domain representation learning; (5) Removing the semantic alignment operator and the semantic-behavior hybrid contrastive learning task both weakens the recommendation performance, which indicates that these two components are irreplaceable.
[0088] Table 1
[0089] Table 2
[0090] In order to further verify the robustness of the model, this paper specifically studies three key parameters: the weight of the semantic-behavioral hybrid enhanced contrastive learning loss, the source domain sequence length, and the target domain sequence length. First, the hyperparameters of the contrastive loss are selected from {0, 0.25, 0.5, 0.75, 1}. , and in Figure 5 ( Figure 5 The horizontal axis is the hyperparameter ) shows the corresponding results, Figure 5 NDCG@10 is N@10, which is the normalized discounted cumulative gain with a parameter of 10. HR@10 is H@10, which is the hit rate index with a parameter of 10. Figure 5 In the left, middle, and right graphs, the upper line represents NDCG@10, and the lower line represents H@10. Figure 5 It can be found that the cross-domain recommendation performance on the three datasets increases with changes with the changes in The best results were obtained with a setting of 0.25.
[0091] In summary, the present invention first designs a cross-attention network based on domain sharing, which effectively captures the text semantic relationship shared between domains by calculating the semantic attention matrix of the source domain and the target domain, and designs a novel cross-domain intention encoder, which aims to adaptively learn the semantic intentions between different domains; secondly, the present invention models user preferences from the dual perspectives of intra-domain preference learning and inter-domain preference learning. In inter-domain preference learning, CT2CSR (CT2CSR is the recommendation method of the present invention) uses the semantic relationship shared between domains as a bridge, combines the user's behavioral preferences in the source domain, and constructs a cross-domain preference representation; while in intra-domain preference learning, CT2CSR decouples fine-grained user intention preferences and coarse-grained text semantic preferences, and aggregates these preferences into intra-domain preferences. Finally, CT2CSR aggregates intra-domain preferences and inter-domain preferences as the final user preference representation; finally, the present method proposes a contrastive learning mechanism based on semantic-behavior hybrid enhancement, which promotes cross-domain knowledge transfer by aligning the inter-domain preference representation and intra-domain preference representation of the same user.
[0092] This embodiment also provides a text-based recommendation device, such as Figure 6 As shown, the device comprises the following components: The semantic intention prediction module 01 is used to obtain a target domain interaction sequence of a user including interactive items, apply a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; apply a semantic intention encoder to the target text semantic representation matrix to obtain the user's semantic intention; The behavior intention prediction module 02 is used to apply the item encoder to the target domain interaction sequence to obtain the item encoding matrix; apply the behavior intention encoder to the item encoding matrix to obtain the user's behavior intention; the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process. The cross-attention mechanism is used to enable the semantic intention encoder to cross-learn in the source domain and the target domain, thereby making the semantic intention encoder a cross-domain encoder; The recommendation module 03 is used to obtain candidate items and item numbers of the candidate items, and generate a text semantic representation matrix of the candidate items, and screen recommended items from the candidate items to be recommended to the user based on the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
[0093] Based on the above embodiments, the present invention further provides a terminal device, whose principle block diagram can be shown as follows: Figure 7As shown. The terminal device includes a processor, a memory, a network interface, and a display screen connected via a system bus. The processor of the terminal device is used to provide computing and control capabilities. The memory of the terminal device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a text-based recommendation method is implemented. The display screen of the terminal device can be a liquid crystal display screen or an electronic ink display screen.
[0094] Those skilled in the art will understand that Figure 7 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0095] In one embodiment, a terminal device is provided. The terminal device includes a memory, a processor, and a text-based recommendation program stored in the memory and executable on the processor. When the processor executes the text-based recommendation program, the following operation instructions are implemented: Obtaining a target domain interaction sequence of a user including interactive items, applying a text encoder to the target domain interaction sequence to obtain text semantics; applying a semantic intent encoder to the text semantics to obtain a semantic intent of the user; Applying an item encoder to the target domain interaction sequence to obtain an item encoding matrix; applying a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention; the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process. The cross-attention mechanism is used to enable the semantic intention encoder to cross-learn in the source domain and the target domain, thereby making the semantic intention encoder a cross-domain encoder; The candidate items and their item numbers are obtained, and the text semantics of the candidate items are generated. According to the text semantics and item numbers of the candidate items and the semantic intention and behavioral intention of the user, the recommended items recommended to the user are screened out from the candidate items.
[0096] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A text-based recommendation method, characterized in that: include: Obtaining a target domain interaction sequence of a user including interactive items, applying a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; Applying a semantic intent encoder to the target text semantic representation matrix to obtain a user's semantic intent; Applying an item encoder to the target domain interaction sequence to obtain an item encoding matrix, applying a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention, wherein the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process, and the cross-attention mechanism is used to enable the semantic intention encoder to perform cross-learning in the source domain and the target domain, so that the semantic intention encoder becomes a cross-domain encoder; Acquire candidate items and item numbers of the candidate items, generate a text semantic representation matrix of the candidate items, and screen recommended items from the candidate items to be recommended to the user based on the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
2. The text-based recommendation method according to claim 1, characterized in that: According to the text semantic representation matrix and the item number of the candidate items and the semantic intention and the behavioral intention of the user, the recommended items are screened out from the candidate items to be recommended to the user, including: Generating an item vector of the candidate item according to the text semantic representation matrix and the item number of the candidate item; Obtaining a user preference vector according to the semantic intention and the behavioral intention, wherein the preference vector is used to represent the user's preference for each of the interactive items; According to the preference vector of the user and the item vector of each of the candidate items, recommended items are screened out from the candidate items to be recommended to the user.
3. The text-based recommendation method according to claim 1, characterized in that: The semantic intention encoder, the text encoder, the object encoder, and the behavior intention encoder adopt a joint training method, wherein the joint training method includes: Setting a text auxiliary encoder and an item auxiliary encoder, wherein the text auxiliary encoder and the item auxiliary encoder are two encoders set for assisting in training the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder; Obtaining the interaction sample sequence of the same user in the source domain and the interaction sample sequence in the target domain; Applying a text-assisted encoder and an item-assisted encoder to the interaction sample sequence of the source domain respectively to obtain a source sample text semantic representation matrix and a source sample item encoding matrix; Applying the text encoder and the object encoder to the interaction sample sequence of the target domain respectively to obtain a target sample text semantic representation matrix and a target sample object encoding matrix; By means of the cross attention mechanism, the inter-domain preference as a positive sample is obtained according to the target sample text semantic representation matrix, the source sample text semantic representation matrix and the source sample item coding matrix; Obtaining the target sample semantic intent through the semantic intent encoder according to the target sample text semantic representation matrix, a neighborhood shared attention matrix composed of the source sample text semantic representation matrix and the target sample text semantic representation matrix; Obtaining the target sample behavior intention according to the target sample item coding matrix through the behavior intention encoder; According to the semantic intention of the target sample and the behavioral intention of the target sample, obtaining an in-domain preference as a positive sample; Obtain the inter-domain preferences of other users and use them as the inter-domain preferences of negative samples; The contrast loss is obtained according to the inter-domain preference as the positive sample, the intra-domain preference as the positive sample, and the inter-domain preference as the negative sample; Based on the contrast loss, a total loss is constructed, and iterative training is performed based on the total loss.
4. The text-based recommendation method according to claim 3, characterized in that: Based on the contrast loss, the total loss is constructed, including: Aggregating the inter-domain preference and intra-domain preference of the same user to obtain the final sample preference of the same user; Obtaining a cross entropy loss according to the text semantic vector and the item number of the candidate item and the final preference of the sample; A total loss is constructed based on the contrast loss and the cross entropy loss.
5. The text-based recommendation method according to claim 3, characterized in that: Through the cross attention mechanism, according to the target sample text semantic representation matrix, the source sample text semantic representation matrix and the source sample item coding matrix, the inter-domain preference as a positive sample is obtained, including: By using the target sample text semantic representation matrix as the query vector of the cross-attention mechanism, the source sample text semantic representation matrix as the key vector of the cross-attention mechanism, and the source sample item coding matrix as the value vector of the cross-attention mechanism, the inter-domain preference as a positive sample is obtained.
6. The text-based recommendation method according to claim 3, characterized in that: The semantic intent encoder obtains the target sample semantic intent according to the target sample text semantic representation matrix, the neighborhood shared attention matrix composed of the source sample text semantic representation matrix and the target sample text semantic representation matrix, including: The target sample text semantic representation matrix is used as the query vector and key vector of the attention mechanism inside the semantic intent encoder to obtain the target domain attention matrix; Merging the neighborhood shared attention matrix and the target domain attention matrix to obtain an attention matrix of shared semantic association; The target sample text semantic representation matrix is used as a value vector and the target sample semantic intent is obtained according to the attention matrix of the shared semantic association.
7. The text-based recommendation method according to any one of claims 1 to 6, characterized in that: The semantic intention and the behavioral intention of the user respectively represent the semantic intention and the behavioral intention reflected by the user's last interaction.
8. A text-based recommendation device, characterized in that: The device comprises the following components: A semantic intention prediction module is used to obtain a target domain interaction sequence of a user including interactive items, and apply a text encoder to the target domain interaction sequence to obtain a target text semantic representation matrix; Applying a semantic intent encoder to the target text semantic representation matrix to obtain a user's semantic intent; A behavior intention prediction module is used to apply an item encoder to the target domain interaction sequence to obtain an item encoding matrix, and apply a behavior intention encoder to the item encoding matrix to obtain the user's behavior intention, wherein the semantic intention encoder, the text encoder, the item encoder, and the behavior intention encoder are all trained encoders, and a cross-attention mechanism for auxiliary training is introduced during the training process, and the cross-attention mechanism is used to enable the semantic intention encoder to perform cross-learning in the source domain and the target domain, so that the semantic intention encoder becomes a cross-domain encoder; The recommendation module is used to obtain candidate items and item numbers of the candidate items, and generate a text semantic representation matrix of the candidate items, and screen recommended items from the candidate items to be recommended to the user based on the text semantic representation matrix and item numbers of the candidate items and the semantic intention and behavioral intention of the user.
9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a text-based recommendation program stored in the memory and executable on the processor. When the processor executes the text-based recommendation program, the steps of the text-based recommendation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a text-based recommendation program, and when the text-based recommendation program is executed by a processor, the steps of the text-based recommendation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Proxy-aware cross-domain sequence recommendation method and device, medium and product
CN116881548A
Dialogue recommendation method based on hypergraph interest learning and semantic fusion
CN118656480A
API sequence recommendation method, storage medium and electronic equipment
CN118861432A
Cross-domain recommendation via contrastive learning of user behaviors in attentive sequence models
US20240161165A1