Recommendation model training and recommendation methods, devices, media and program products
By introducing task-aware tags and importance weights into the decoder, the problem that traditional generative recommendation models cannot distinguish between different user behavioral intentions is solved, and end-to-end joint optimization of generation and ranking tasks is achieved, thereby improving recommendation accuracy.
Patent Information
- Application Number
- CN202610994014.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-03
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional generative recommendation models cannot effectively distinguish and optimize users' differentiated intentions under different behavior types, resulting in low recommendation accuracy.
By introducing task-aware labels and importance weights into the decoder, we can achieve differentiated generation and collaborative optimization of semantic label sequences under different behavior types. Furthermore, we can reuse the behavior-aware representations from the generation stage to the sorting module, enabling the sorting loss gradient to be backpropagated to the generation path, thus achieving end-to-end joint optimization of the generation task and the multi-objective sorting task.
This improves recommendation accuracy and ensures consistency between the generated semantic tag sequence and the user's actual preference distribution.
Smart Images

Figure CN123118183A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of computer technology, and more particularly to a method, apparatus, medium, and program product for training and recommending a recommendation model. Background Technology
[0002] In e-commerce platforms, recommendation systems play a crucial role. Traditional recommendation systems typically employ a cascaded pipeline architecture of recall and ranking. The recall and ranking modules independently optimize their respective local subtasks. The ranking module can only process the candidate set filtered by the recall module, and items that were filtered out in the early stages but may have high value cannot be recovered, thus limiting the overall system performance. To address this, generative recommendation has been proposed, which transforms the recommendation problem into a sequence generation task, directly generating semantic tag sequences for items. However, current generative recommendation models are trained with the goal of maximizing the predicted probability of the next semantic tag in the sequence. In real-world recommendation scenarios, user behavior feedback is usually of multiple types (such as clicks, adding to cart, purchasing, etc.). This objective cannot effectively distinguish and coordinate the optimization of differentiated user intentions under different behavior types, causing the value distribution of the semantic tag sequences generated by the model to deviate from the user's true preference distribution, resulting in low recommendation accuracy. Summary of the Invention
[0003] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a method for training a recommendation model is proposed, the recommendation model including an encoder, a decoder, and a ranking module; the method includes: Obtain a first training sample, which includes: a first user history interaction sequence of the target user, and multiple sample semantic identifier sequences corresponding to the next interactive item in the first user history interaction sequence; the multiple sample semantic identifier sequences correspond to multiple preset behavior types respectively; The encoder encodes the first user's historical interaction sequence to obtain a first user representation; The task-aware labels corresponding to the various behavior types are determined, and the semantic identifier sequences of the multiple samples are concatenated with the corresponding task-aware labels to obtain the input sequence; the task-aware labels are learnable vectors used to indicate the task type of the prediction task. The input sequence is decoded by the decoder. Based on the first user representation and the hidden state corresponding to each behavior type output by the decoder during the decoding process, the semantic identifier sequence of the user's next interactive item is independently predicted for each behavior type. The prediction loss under each behavior type is determined based on the predicted semantic identifier sequence and the sample semantic identifier sequence corresponding to each behavior type. The prediction loss under the corresponding behavior type is weighted according to the importance weight corresponding to each behavior type to obtain the weighted prediction loss. The first user representation is concatenated with the hidden state corresponding to each behavior type to obtain the user behavior intent vector corresponding to each behavior type. The user behavior intent vector corresponding to each behavior type is input into the sorting module to obtain the preference prediction score of the predicted semantic identifier sequence under each behavior type. The sorting loss is determined based on the preference prediction score under each behavior type. The total loss is determined based on the weighted prediction loss and the ranking loss, and the parameters of the recommendation model are optimized based on the total loss.
[0004] According to a second aspect of one or more embodiments of this specification, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the steps of the method described in the first aspect of one or more embodiments of this specification by executing the executable instructions.
[0005] According to a third aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method described in the first aspect of one or more embodiments of this specification.
[0006] According to a fourth aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the method described in the first aspect of one or more embodiments of this specification.
[0007] This specification's embodiments acquire multiple sample semantic identifier sequences of the next interactive item and set task-aware labels as learnable vectors for different behavior types. These labels are concatenated with the sample sequences and input into a decoder, enabling the decoder to explicitly distinguish different behavioral features and independently predict the semantic identifier sequences for each behavior type. By setting importance weights to weight the prediction loss, different behaviors are given differentiated priorities during the generation stage, solving the problem that existing models cannot collaboratively optimize differentiated intentions with a single objective. Furthermore, the first user representation is concatenated with the hidden states of each behavior type output by the decoder to construct a user behavior intention vector, which is then input into the ranking module. This allows the ranking module to reuse the behavior-aware representation from the generation stage to calculate preference scores, enabling the ranking loss gradient to be backpropagated to the generation path through shared representations. Consequently, the optimization objective of the ranking module directly participates in adjusting the predicted probability distribution of semantic identifiers under each behavior type during training. Through the above methods, this specification achieves end-to-end joint optimization of the generation and ranking tasks under shared decoder parameters. This ensures that the generation process of the semantic identifier sequence is guided by the ranking results, thereby improving the consistency between the generated semantic identifier sequence and the value distribution and the user's true preference distribution across different behavior types, and improving recommendation accuracy. Attached Figure Description
[0008] Figure 1 This is a schematic diagram of the architecture of a recommendation model in related technologies.
[0009] Figure 2 This is a schematic diagram of a recommendation model provided in an exemplary embodiment of this specification.
[0010] Figure 3 This is a flowchart illustrating a training method for a recommendation model provided in an exemplary embodiment of this specification.
[0011] Figure 4 This is a flowchart of a recommended method provided in an exemplary embodiment of this specification.
[0012] Figure 5 This is a schematic diagram of the structure of a device provided in an exemplary embodiment of this specification. Detailed Implementation
[0013] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0014] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with relevant laws, regulations and standards, and corresponding operation entry points shall be provided for users to choose to authorize or refuse.
[0015] In e-commerce platforms, recommendation systems play a crucial role. Traditional industrial-grade recommendation systems typically employ a multi-stage cascaded pipeline architecture. Figure 1 The diagram illustrates the cascaded architecture of a traditional recommendation system. This architecture sequentially includes a recall module, a coarse ranking module, a fine ranking module, and a re-ranking module. These modules are connected in series along the pipeline, with the candidate product set being progressively filtered and reduced as it flows through each module. Specifically, the recall module quickly and initially filters out a coarse candidate set from the product library; the coarse ranking module performs preliminary scoring and truncation of the recall results; the fine ranking module uses deep learning models and various feature information to perform a refined multi-objective utility evaluation of the candidate products output by the coarse ranking module; and the re-ranking module adjusts the fine ranking results according to preset rules and constraints. In this cascaded architecture, each module independently optimizes its local subtasks, making it difficult to achieve a global optimum. Furthermore, the downstream ranking module can only re-rank the candidate products retained by the upstream module; products that were filtered out in the recall phase but may have high value to the user cannot be recovered in subsequent stages, thus limiting the overall system performance.
[0016] To alleviate the problems of fragmented objectives and progressive information loss in cascaded architectures, generative retrieval paradigms have been proposed. Generative retrieval transforms the recommendation problem into a sequence generation task, directly generating semantic tag sequences for items. However, there is an inconsistency between the training objectives of traditional generative retrieval and those in real-world scenarios. Traditional generative retrieval models typically use maximizing the predicted probability of the next semantic tag in the sequence as their training objective. This objective is essentially a language model-like autoregressive likelihood maximization objective, focusing only on generating semantically plausible candidate products. In actual e-commerce recommendation scenarios, user behavior towards products typically manifests in multiple types, such as browsing, adding to cart, and placing an order. The intent implied by different behavior types varies significantly. Traditional NTP objectives treat all behavior types equally, failing to effectively distinguish and optimize the differentiated intents of users under different behavior types. This leads to a deviation between the value distribution of the semantic tag sequences generated by the model across different behavior types and the user's true preference distribution, resulting in low recommendation accuracy.
[0017] Based on this, this specification proposes a recommendation scheme based on the unification of semantic tag generation and multi-objective ranking. By introducing task-aware tags and importance weights into the decoder, it realizes differentiated generation and collaborative optimization of semantic tag sequences under different behavior types. Furthermore, the behavior-aware representation in the generation stage is reused in the ranking module, and the ranking loss gradient is backpropagated to the generation path, thereby achieving end-to-end joint optimization of the generation task and the multi-objective ranking task, which effectively improves the recommendation accuracy.
[0018] like Figure 2 As shown, the recommended model in this embodiment includes an encoder, a decoder, and a sorting module. Based on Figure 2 The recommendation model shown in this specification provides a training method for the recommendation model, such as... Figure 3 As shown, the method includes: Step S102: Obtain the first training sample, which includes: the first user history interaction sequence of the target user, and multiple sample semantic identifier sequences corresponding to the next interactive item in the first user history interaction sequence; the multiple sample semantic identifier sequences correspond to multiple preset behavior types respectively; Step S104: Encode the historical interaction sequence of the first user using an encoder to obtain the first user representation; Step S106: Determine the task-aware labels corresponding to various behavior types, and concatenate multiple sample semantic identifier sequences with the corresponding task-aware labels to obtain the input sequence; the task-aware label is a learnable vector used to indicate the task type of the prediction task. Step S108: Decode the input sequence using a decoder. Based on the first user representation and the hidden states corresponding to each behavior type output by the decoder during the decoding process, independently predict the semantic identifier sequence of the user's next interactive item for each behavior type. Determine the prediction loss for each behavior type based on the predicted semantic identifier sequence and the sample semantic identifier sequence. Then, weight the prediction loss for the corresponding behavior type according to the importance weight of each behavior type to obtain the weighted prediction loss. Step S110: Concatenate the first user representation with the hidden state corresponding to each behavior type to obtain the user behavior intent vector corresponding to each behavior type. Input the user behavior intent vector corresponding to each behavior type into the sorting module to obtain the preference prediction score of the predicted semantic identifier sequence under each behavior type. Determine the sorting loss based on the preference prediction score under each behavior type. Step S112: Determine the total loss based on the weighted prediction loss and ranking loss, and optimize the parameters of the recommendation model based on the total loss.
[0019] The specific implementation details of the embodiments in this specification are illustrated below.
[0020] In step S102, a first training sample can be obtained. For example, the first training sample can be obtained from user historical behavior logs collected by the recommendation system in a specific application scenario, such as the homepage recommendation scenario or the search results page recommendation scenario of an e-commerce platform. The user historical behavior log can record at least some of the following information: user identifier, item identifier of the user-interacted item, interaction time, interaction behavior type, and user characteristics, item characteristics, and contextual characteristics.
[0021] The first training sample may include the target user's first user history interaction sequence. This sequence may include multiple items the target user interacted with during a historical time period. These interactions can correspond to various behavior types, such as clicking, adding to cart, and purchasing. As a possible example, when the first user history interaction sequence only contains item identifiers, it can be represented in the form of {Item A, Item B, Item C, ...}. Furthermore, the first user history interaction sequence can also include the behavior type corresponding to each item to reflect the target user's specific intent when interacting with each item. For example, a first user history interaction sequence including behavior types could be represented in the form of {Item A (click), Item B (click), Item B (add to cart), Item C (purchase), ...}, where the same item may involve different behavior types at different times.
[0022] The first training sample may also include multiple sample semantic label sequences corresponding to the next interactive item in the first user's historical interaction sequence. These multiple sample semantic label sequences correspond to various preset behavior types. Here, the next interactive item refers to the target item for which the target user actually performs an interaction after the last interaction recorded in the first user's historical interaction sequence. The sample semantic label sequences corresponding to the next interactive item can serve as labels for the recommendation model to predict the semantic label sequences of each behavior type during the generation phase. For example, assuming the preset behavior types include click, add to cart, and purchase, and the target user's actual behavior after the first user's historical interaction sequence is: the next clicked item is product D, the next add-to-cart item is product E, and the next purchase item is product F, then the first training sample may include sample semantic label sequences for product D, product E, and product F, corresponding to click, add to cart, and purchase behaviors, respectively. These sample semantic label sequences are used to supervise the recommendation model's learning to generate correct semantic label sequences for different behavior types such as click, add to cart, and purchase, given the first user's historical interaction sequence.
[0023] In step S104, the first user's historical interaction sequence can be encoded by an encoder to obtain the first user representation. In an optional implementation, the encoder can employ an attention-based architecture (e.g., a Transformer encoder). Specifically, an attention-based encoder can capture long-distance dependencies and sequence context information between items by calculating the self-attention weights between each item in the first user's historical interaction sequence. However, attention-based encoders suffer from high computational complexity; their computational and memory consumption increase quadratically with the length of the first user's historical interaction sequence, leading to high online inference latency and computational bottlenecks when the first user's historical interaction sequence is long. To address these issues, the encoder in this specification employs a lightweight architecture (MemoryNet), avoids self-attention mechanisms, achieves linear complexity O(L) by processing the behavior sequence through positional encoding and linear projection, and uses a multilayer perceptron to perform non-linear mapping on the user profile features as a prefix label.
[0024] Specifically, the encoder may include a multilayer perceptron. The process of encoding the first user's historical interaction sequence to obtain the first user representation may include: combining the semantic identifier of each item in the first user's historical interaction sequence with the corresponding behavior type information and location information to obtain the encoded representation of the item; performing positional encoding and linear projection processing on the sequence including the encoded representations of each item to obtain the memory representation; mapping the user profile features of the target user through the multilayer perceptron to obtain the user profile representation vector, and adding the user profile representation vector as a prefix to the beginning of the memory representation to obtain the first user representation.
[0025] Semantic identifier embedding is obtained by embedding the semantic identifier sequence of items. A semantic identifier sequence is a string of discrete identifiers obtained by quantizing the features of an item using a quantization model (such as a residual quantization variational autoencoder). The semantic identifier sequence has a hierarchical semantic structure; its prefix identifier usually represents coarse-grained category information of the item, while subsequent identifiers are progressively refined to specific item instances. Therefore, it can reflect the clustering relationships and similarities of items in the semantic space.
[0026] In some embodiments, semantic identifier embedding can be obtained by: acquiring multimodal features of an item, the multimodal features including textual metadata and visual features of the item; inputting the multimodal features into a multimodal encoder to obtain a multimodal embedding vector of the item; performing residual quantization encoding on the multimodal embedding vector to generate a semantic identifier sequence of the item; the semantic identifier sequence includes semantic identifiers at multiple levels; and performing embedding processing on the semantic identifiers at each level in the semantic identifier sequence to obtain the semantic identifier embedding.
[0027] The textual metadata can include structured or unstructured textual information such as the item's title, description text, brand name, category name, specifications, and user reviews. Visual features can include image feature vectors extracted from the item's main image and detail images using a pre-trained multimodal model. The recommendation model inputs these multimodal features into a multimodal encoder, performing cross-modal alignment and deep fusion of textual and visual information to output a multimodal embedding vector that simultaneously represents the item's textual semantics and visual appearance. The recommendation model can then perform residual quantization encoding on the multimodal embedding vector. Specifically, residual quantization encoding can approximate the multimodal embedding vector layer by layer using a multi-level codebook: the first-level codebook finds the codeword closest to the multimodal embedding vector and records the corresponding first-level semantic identifier, then calculates the residual vector; the second-level codebook quantizes the residual vector again and records the second-level semantic identifier, and so on, until a semantic identifier sequence containing multiple levels of semantic identifiers is generated. The recommendation model can also embed semantic tags at each level in the semantic tag sequence separately, and aggregate (e.g., concatenate) the resulting multiple embedding vectors to obtain the semantic tag embedding of the item.
[0028] Behavior type information can be an identifier used to uniquely identify a specific behavior type (e.g., using different integer indices or one-hot encoding to represent different behavior types), uniquely identifying each behavior type. Its corresponding embedding vector enables the recommendation model to learn the specific intent of a user when interacting with the item. Location information is used to represent the item's position in the first user's historical interaction sequence (e.g., which position the item is in the first user's historical interaction sequence), and its corresponding location embedding vector enables the recommendation model to perceive the temporal relationship of the behavior.
[0029] After obtaining the semantic identifier embedding of the item, the embedding corresponding to the behavior type information, and the embedding corresponding to the location information, these three parts of information can be combined by concatenation or element-by-element addition to obtain an encoded representation that integrates the semantics of the item, the interaction intent, and the temporal location.
[0030] After obtaining the encoded representations of each item in the first user's historical interaction sequence, the recommendation model can arrange these encoded representations into a sequence. To further enhance the absolute or relative positional information of the sequence, the recommendation model can perform positional encoding on the sequence again, and then use a linear projection layer (such as a fully connected layer) to perform dimensional transformation and feature mapping on the positionally encoded sequence, projecting it onto the hidden layer dimensional space that matches the subsequent decoder, thereby obtaining a memory representation.
[0031] Furthermore, after positional encoding, the positionally encoded sequence can be subjected to random dropout processing, followed by dimensionality transformation and feature mapping through a linear projection layer. Random dropout refers to setting the values of some data elements in the sequence features (e.g., the entire feature vector of some items in the sequence, or some feature dimensions in the feature vector) to zero according to a preset dropout probability during the training process of the recommendation model. This prevents these zeroed feature information from participating in the forward propagation calculation of the current training round. For example, suppose that after positional encoding, the sequence contains feature vectors of 10 items, and each feature vector contains 128 feature dimensions. If the probability of random deactivation is set to 20%, then in each training iteration of the recommendation model, 20% of the feature elements can be randomly selected (for example, randomly masking all features of a few items, or randomly masking certain dimensions of all item features) and their values can be forcibly set to 0, while the remaining 80% of the feature elements retain their original values and participate in subsequent linear projection calculations. In the next training iteration, another 20% of the feature elements are randomly selected again and set to zero, so that the sequence features input to the linear projection layer are different each time. In this way, the model's over-reliance on specific local features or a few key items in the first user's historical interaction sequence can be broken (i.e., feature co-adaptation is prevented), effectively preventing the trained recommendation model from overfitting.
[0032] In some embodiments, the semantic identifier sequence has multiple levels. During decoding, the decoder can add learnable token type embeddings (TTEs) to the semantic identifier embeddings to encode the hierarchical structure information of the semantic identifiers. Semantic identifiers at different levels have different semantic meanings. Upper-level semantic identifiers are used to capture coarse-grained semantic clustering, such as representing the broad category to which an item belongs (e.g., electronic products or mobile phones), while lower-level semantic identifiers are used to provide fine-grained differentiation and item uniqueness, such as representing the specific model number or unique product ID of an item. To enable the model to explicitly perceive and distinguish these hierarchical differences, this embodiment assigns an independent learnable vector to each level of the semantic identifier as the token type embedding (TTE) for that level. After mapping the semantic identifiers to embedding vectors, the decoder fuses the TTEs of the corresponding level with the semantic identifier embeddings (e.g., by addition or concatenation), thereby injecting hierarchical position information into the feature representation. In this way, the confusion of semantic information from different levels in the feature space can be effectively avoided, allowing the decoder to clearly know which level of identifier it is currently processing or predicting.
[0033] In addition to sequential behavioral features, target users also possess relatively stable static attribute features (such as age, gender, region, and long-term interest tags), i.e., user profile features. The recommendation model can use a multilayer perceptron in the encoder to perform a non-linear mapping of the target user's user profile features, transforming them into a user profile representation vector within the same feature space as the sequential features. This user profile representation vector is then used as a prefix, concatenated or added to the beginning of the memory representation sequence to obtain the first user representation. In this way, the first user representation not only includes the dynamic sequential memory of the user's historical behavior but also injects user profile features into the beginning of the sequence. This allows the subsequent decoder, when generating semantic label sequences through autoregression, to be simultaneously guided by both the user's long-term profile and short-term behavioral intentions.
[0034] In step S106, task-aware labels corresponding to various behavior types can be determined, and multiple sample semantic identifier sequences are concatenated with their corresponding task-aware labels to obtain an input sequence. The task-aware label is a learnable vector indicating the task type of the prediction task. The task-aware label indicates the specific prediction task type to be performed, such as predicting the next item the target user will click (click prediction task), predicting the next item the target user will add to their cart (add-to-cart prediction task), or predicting the next item the target user will purchase (purchase prediction task), etc. In some embodiments, the task-aware label can be a learnable vector indicating the task type of the prediction task. This learnable vector can be set as a random vector or pre-trained vector with a specific dimension (usually the same as the hidden layer dimension) during the initialization of the recommendation model. During the training of the recommendation model, these learnable vectors can be used as part of the model parameters and jointly optimized end-to-end with other weights in the recommendation model through backpropagation. As training progresses, the task-aware labels corresponding to different behavior types will gradually converge and learn feature representations that can accurately stimulate the recommendation model to generate corresponding behavior sequences. By assigning unique task-aware labels to each behavior type, the recommendation model can perform unified modeling of multiple tasks using the same autoregressive generative network without adding extra network branches or decoders.
[0035] After determining the task-aware labels corresponding to each behavior type, an input sequence for training the decoder can be constructed. Specifically, for each sample semantic label sequence in the first training sample (i.e., the semantic label sequence of the next interactive item as a label), the recommendation model can obtain the task-aware label of its corresponding behavior type and concatenate the task-aware label to the beginning of the sample semantic label sequence. For example, each task-aware label can be concatenated as a global prefix to the beginning of the input sequence. Suppose the model needs to predict three target items for the user in the future simultaneously: item A (corresponding to click behavior), item B (corresponding to add-to-cart behavior), and item C (corresponding to purchase behavior), and the semantic label sequence of each item contains 3 levels, such as {s1, s2, s3}, and assume that the multiple task-aware labels are (T click T act and T pay ), where T click T represents the task-aware marker corresponding to the clicked prediction task. act T represents the task-aware tag corresponding to the add-to-cart prediction task. pay If the task-aware tag corresponding to the purchase prediction task is represented, then after concatenation, the complete input sequence to the decoder can be denoted as: {T click T act T pay ,sA1,sA2,sA3,sB1,sB2,sB3,sC1,sC2,sC3}.
[0036] Wherein, sA1, sA2, and sA3 are the three levels of semantic identifiers in the semantic identifier sequence of item A, sB1, sB2, and sB3 are the three levels of semantic identifiers in the semantic identifier sequence of item B, and sC1, sC2, and sC3 are the three levels of semantic identifiers in the semantic identifier sequence of item C.
[0037] In some embodiments, the decoder includes an attention layer that employs a self-attention mechanism for decoding. The self-attention mechanism, by default, allows global interaction between sequence elements. To prevent future information leakage and padding interference during autoregressive generation, a mask is typically applied to block irrelevant information. However, the sample semantic identifier sequences in the embodiments of this specification contain multiple multi-level sequences, and in multi-object modeling scenarios, the input sequence is concatenated with the semantic identifier sequences of multiple target items. Using a traditional single causal mask would lead to forced dependencies and information interference between different sequences. Therefore, this embodiment proposes a custom causal mask to finely control the information flow within complex sequences.
[0038] Specifically, the process of decoding the input sequence through the decoder may specifically include: applying a custom causal mask to the input sequence, and in the attention layer, adopting an attention mechanism to decode the input sequence to which the custom causal mask has been applied; wherein the custom causal mask is configured to: within the sample semantic identifier sequence corresponding to the same target item, constrain the semantic identifier at each level to be visible only to itself and the semantic identifiers at preceding levels, and invisible to the semantic identifiers at subsequent levels; and between the sample semantic identifier sequences corresponding to different target items, constrain their semantic identifiers to be mutually invisible, so as to realize parallel prediction of multiple concurrent interest targets in the same session.
[0039] The custom causal mask can control the visibility between sequence elements by constructing a specific attention mask matrix. The element values in the mask matrix can be set binarized to 0 or negative infinity. For the interior of the sample semantic identifier sequence corresponding to the same item, assuming that the sequence includes L levels, and its local index range in the input sequence is [start, start+L-1]. The recommendation model constructs a lower triangular structure in the L×L submatrix of the mask matrix corresponding to the local index range: for the element at the i-th row and j-th column in the submatrix (representing the attention weight of the i-th level to the j-th level), when i≥j (that is, the current level pays attention to itself or the levels before it), the mask element is assigned a value of 0, so that the corresponding initial attention score remains unchanged after addition, thereby allowing information transmission; when i<j (that is, the current level attempts to pay attention to the levels after it), the mask element is assigned a value of -∞. In the subsequent Softmax normalization calculation, the score added with -∞ will be converted into a probability weight close to 0, thereby physically cutting off the attention connection from the preceding levels to the subsequent levels. In this way, the autoregressive hierarchical progressive logic of semantic generation within the same item is ensured, so that the recommendation model can follow the order of predicting coarse-grained semantic categories first and then gradually refining the semantic categories to restore the semantic identifier sequence of the target item.
[0040] In the recommendation model described in this specification, to distinguish and jointly predict multiple user interaction intentions, the input sequence is concatenated with task-aware tags corresponding to various behavior types and sample semantic identifier sequences of the target item. To provide conditional information about behavior types, this embodiment pre-concatenates the task-aware tags corresponding to multiple behavior types before the sample semantic identifier sequence. However, in traditional multi-task sequence modeling, task-aware tags often employ a globally visible or uniformly causally visible strategy. This can easily lead to the representation of low-priority behaviors (such as clicks) prematurely perceiving the semantic content of high-priority behaviors (such as purchases), causing tag leakage and feature interference, making it difficult for the recommendation model to learn purely behavior-specific representations. To solve this problem, this specification uses a custom causal mask to differentially control the attention range between task tags and semantic identifiers, achieving interference-free injection of multi-task conditional information.
[0041] Specifically, various behavior types can include click behavior, add-to-cart behavior, and purchase behavior. A custom causal mask is configured as a funnel-shaped attention mask to model the user intent progression funnel of "click → add-to-cart → purchase". The custom causal mask is used to: constrain the click task perception marker in the sample semantic identifier sequence to focus only on the click task perception marker itself, excluding the add-to-cart and purchase task perception markers; the add-to-cart task perception marker to focus only on the click task perception marker and the add-to-cart task perception marker, excluding the purchase task perception marker; and the purchase task perception marker to focus on the click task perception marker, the add-to-cart task perception marker, and the purchase task perception marker. This design allows the task markers of high-priority behaviors (such as purchase) to accumulate the intent signals of low-priority behaviors, while low-priority behaviors cannot perceive high-priority information in reverse, effectively avoiding label leakage and ensuring the independence of each behavior prediction task.
[0042] Assuming the input sequence is concatenated in the order of "click task marker + add-to-cart task marker + purchase task marker + semantic identifier sequence of the target item," the rows in the mask matrix corresponding to each level of the semantic identifier sequence are all set to 0 in the column areas corresponding to the click, add-to-cart, and purchase task awareness markers (allowing attention to preceding task markers), while other irrelevant areas are set according to the parallel masking rules between items. For rows corresponding to the click task marker, only the column area corresponding to itself is set to 0, while the column areas corresponding to the add-to-cart and purchase task markers are set to negative infinity. For rows corresponding to the add-to-cart task marker, the column areas corresponding to the click and itself are set to 0, while the column area corresponding to the purchase task marker is set to negative infinity. For rows corresponding to the purchase task marker, the column areas corresponding to the click, add-to-cart, and itself are all set to 0. This row-by-row differentiated masking method precisely defines the information flow boundaries under the funnel structure, ensuring that task markers can only be injected hierarchically as conditional signals, and will not retrieve the semantic content of high-priority behaviors in reverse.
[0043] Furthermore, to ensure the standardization of the autoregressive generation, special control tokens can be introduced during concatenation. For example, a start token (BOS Token) can be inserted between the task-aware token and the sample semantic identifier sequence, and / or an end token (EOS Token) can be added to the end of the sequence. The final concatenated complete input sequence (e.g., "[Click task-aware token]+[Add to cart task-aware token]+[Purchase task-aware token]+[BOS]+[Semantic identifier sequence of product D]+[EOS]") will be fed into the decoder. During the training phase, the decoder can use this input sequence combined with the first user representation output by the encoder to progressively predict the semantic identifiers of the next level through an autoregressive mechanism, and calculate the loss between the prediction results and the true labels. This supervises the model's learning to accurately generate item semantic identifier sequences corresponding to different behavior types under the guidance of different task-aware tokens.
[0044] In the presence of a starter marker, the custom causal mask is further used to ensure that all levels of semantic identifiers in the semantic identifier sequence of all samples are visible to the starter marker, while the starter marker is also visible to all preceding task-aware markers. Specifically, in the mask matrix, the column corresponding to the starter marker in the row containing the semantic identifier is set to 0, allowing the starter marker to be perceived by all subsequent levels as a global context anchor; the column region corresponding to the preceding task-aware marker in the row containing the starter marker is also set to 0, enabling it to aggregate conditional information from multiple tasks. This design ensures that the starter marker can stably provide a unified initial condition injection for the entire sequence generation, and unifies the representations of different items in the same context space, ensuring that the autoregressive generation process always follows a coarse-to-fine decoding logic.
[0045] In step S108, the input sequence can be decoded by the decoder. Based on the first user representation and the hidden state corresponding to each behavior type output by the decoder during the decoding process, the semantic identifier sequence of the user's next interactive item is predicted independently for each behavior type. Based on the predicted semantic identifier sequence and sample semantic identifier sequence corresponding to each behavior type, the prediction loss under each behavior type is determined. Based on the importance weight corresponding to each behavior type, the prediction loss under the corresponding behavior type is weighted to obtain the weighted prediction loss.
[0046] When predicting semantic tag sequences based on hidden states, the decoder maps the hidden states output from each decoding step to the semantic tag codebook space through an output projection layer, obtaining the predicted probability distribution of each candidate semantic tag in the codebook corresponding to the current decoding step. Specifically, for the j-th level in the semantic tag sequence, the decoder predicts the probability distribution of the j-th level semantic tag using an autoregressive mechanism based on the semantic tags of the first j-1 levels already generated, the first user representation, and the preceding context in the input sequence. The recommendation model can take the candidate semantic tag with the highest probability as the prediction result for the current level, or directly use this probability distribution and the true label to calculate the loss during the training phase. Through layer-by-layer autoregressive decoding, the recommendation model can independently generate a complete predicted semantic tag sequence for each behavior type. This sequence contains predicted semantic tags at multiple levels, gradually refining from coarse-grained semantic categories to specific item instances.
[0047] The decoder in the embodiments of this specification adopts an architecture based on an autoregressive language model, comprising multiple stacked decoder layers, each including an attention layer and an expert network layer. The attention layer can employ a Grouped Query Attention (GQA) mechanism (e.g., every four query headers share one key-value header) to reduce key-value cache overhead. The attention layer models the intra-sequence dependencies of the input units of the current input (the input units are semantic identifiers or task-aware tags), and outputs an intermediate representation containing contextual information.
[0048] In related technologies, the feedforward network layer of the decoder typically employs a dense structure, meaning all input features are processed through the same fully connected network parameters. However, user interests and item semantics in recommendation scenarios are diverse. Dense networks, limited by fully shared parameters, struggle to simultaneously extract general recommendation patterns and differentiate modeling specific sub-interests, easily leading to negative transfer between different patterns and insufficient representation of long-tail interests. To address this issue, this specification proposes a hybrid expert architecture. Specifically, the expert network layer in the decoder is configured to include a shared expert network and multiple routing expert networks. The expert network layer receives intermediate representations from the attention layer as input. During decoding, for the intermediate representation corresponding to the current input unit, the routing network calculates the matching weights between the intermediate representation and each routing expert network. Based on the matching, several routing expert networks are activated, and the output of the input unit after passing through the expert network layer is determined based on the outputs of the activated routing expert networks and the shared expert network. The input unit is a semantic identifier or task-aware label. The shared expert network is used to capture general recommendation patterns, while multiple routing expert networks are used to differentiate input features for different semantic subspaces or different user interest patterns.
[0049] In the above process, the shared expert network processes all intermediate representations and is responsible for extracting globally common recommendation features (such as basic click preferences), while multiple routing expert networks process features of specific semantic subspaces or interest patterns. The routing network, as a lightweight gating network, selects the top-K routing expert networks with the highest scores for activation by calculating matching weights; unactivated experts do not participate in the current calculation. This sparse activation mechanism effectively controls the computational complexity of a single inference while expanding the model's parameter capacity. The recommendation model can then weight and fuse the outputs of the activated routing expert networks with the shared expert network. Through this mechanism, the ability to model complex and diverse user interests can be effectively improved without significantly increasing the computational load of inference, mitigating the negative transfer problem between different interest patterns.
[0050] After obtaining the predicted semantic identifier sequences corresponding to each behavior type, the recommendation model can determine the prediction loss for each behavior type based on the predicted semantic identifier sequences and the sample semantic identifier sequences. The prediction loss can be the cross-entropy loss, which essentially measures the difference between the probability distribution of the predicted semantic identifier sequences and the actual sample semantic identifier sequences.
[0051] Since different behavior types have different values in real-world business scenarios, recommendation models can assign importance weights to each behavior type. Importance weights reflect the relative importance of the corresponding behavior type to the business objective, and their values are positively correlated with the value of that behavior type. For example, in e-commerce recommendation scenarios, purchasing behavior has the highest value, followed by adding to cart, then clicking, and exposure behavior has the lowest. Therefore, purchasing behavior can be assigned the highest importance weight, adding to cart can be assigned a medium importance weight, and clicking can be assigned a low importance weight. Importance weights can be preset by those skilled in the art based on business needs, or they can be quantified by statistically analyzing the conversion rate or revenue contribution of each behavior type in historical behavior logs. After determining the importance weights for each behavior type, the recommendation model can weight the prediction loss for the corresponding behavior type to obtain a weighted prediction loss.
[0052] In step S110, the first user representation is concatenated with the hidden state corresponding to each behavior type to obtain the user behavior intent vector corresponding to each behavior type. The user behavior intent vector corresponding to each behavior type is input into the sorting module to obtain the preference prediction score of the predicted semantic identifier sequence under each behavior type. The sorting loss is determined based on the preference prediction score under each behavior type.
[0053] The hidden state encodes high-order interaction information between the semantic identifier of the target item and the user representation, as well as the user's intent preference under the corresponding behavior type. This step, through concatenation, integrates the user's long short-term memory and high-order interaction features into the user's behavioral intent vector, comprehensively representing the user's overall intent under a specific behavior type. After obtaining the user behavioral intent vector corresponding to each behavior type, the recommendation model can input it into the ranking module to obtain the preference prediction score of the predicted semantic identifier sequence under each behavior type. The ranking loss is then determined based on the difference between the preference prediction score and the actual behavior label under each behavior type. The ranking loss can employ binary cross-entropy loss. Since the ranking module and decoder share the semantic identifier representation and hidden state, the gradient generated by the ranking loss can propagate back to the decoder parameters, directly guiding the semantic identifier sequence generated by the decoder to optimize in a direction more beneficial to downstream business objectives during training, achieving end-to-end joint optimization of the generation task and the multi-objective ranking task.
[0054] In some embodiments, the ranking module includes a target attention submodule and a multi-target ranking submodule based on Progressive Hierarchical Extraction (PLE). The target attention submodule employs a cross-attention mechanism, using the semantic ID representation of candidate items as the query vector and the encoded representation of the first user's historical interaction sequence as the key and value vectors. By calculating attention weights, it dynamically locates the interaction segment most relevant to the current candidate item from the first user's historical interaction sequence, obtaining the target attention output, thereby achieving fine-grained user interest activation. Further, the PLE multi-target ranking submodule includes a shared expert network and a task-specific expert network. The PLE multi-target ranking submodule can acquire user information, semantic ID representation, the aforementioned target attention output, and decoder representation as multi-source input features. The shared expert network learns common features among multiple ranking targets based on the multi-source input features, while the task-specific expert network learns personalized features for each ranking target based on the multi-source input features. The PLE multi-target ranking submodule also includes a gating network, which dynamically allocates weights between the shared expert network and the task-specific expert network according to the input samples, extracting high-order features through layer-by-layer routing to output the multi-target ranking result. The above architecture can mitigate the negative transfer effect caused by weak correlations or conflicts between objectives in multi-task learning, and output accurate ranking results while balancing multiple objectives.
[0055] In step S112, the total loss can be determined based on the weighted prediction loss and the ranking loss. For example, the total loss can be obtained by weighting the weighted prediction loss and the ranking loss, and the parameters of the recommendation model can be optimized based on the total loss.
[0056] In the joint training of multi-task or multi-objective recommendation systems, model parameters are typically optimized directly using the cross-entropy loss of the generation task and the classification loss of the ranking task. However, the distribution of task-aware labels corresponding to different behavior types in the feature space often overlaps or becomes confused. Relying solely on generation and ranking losses is insufficient to enable the model to effectively distinguish the intent of different behavior types in the representation space. This results in the task-aware label representations output by the decoder lacking sufficient discriminative power for different behavior types, affecting the accuracy of multi-objective ranking. To address this issue, this embodiment introduces a contrastive learning mechanism to enhance the discriminative power of representations for different behavior types.
[0057] Specifically, for each task-aware label corresponding to a behavior type, the output vector of the task-aware label in the decoder can be obtained. The embedding vectors of positive sample items with the corresponding behavior type in the first training sample are taken as positive examples, and the embedding vectors of negative sample items without the corresponding behavior type in the first training sample are taken as negative examples. The output vectors are compared and learned to obtain the auxiliary comparison loss. The total loss is determined based on the weighted prediction loss, the ranking loss and the auxiliary comparison loss.
[0058] In this context, positive sample items refer to items that the user actually generated the corresponding behavior type during their historical interactions. For example, for the purchase behavior type, positive sample items are the products the user actually ordered; for the click behavior type, positive sample items are the products the user actually clicked and viewed on the page. Negative sample items refer to items that the user did not generate the corresponding behavior type during their historical interactions. These can be randomly sampled uninterrupted items, items that were exposed but not clicked, or items that were clicked but not purchased. For example, when performing contrastive learning for purchase behavior, negative sample items could be products that the user only clicked but did not purchase, or other products that were not exposed to the user at all. By constructing such positive and negative sample pairs, contrastive learning can guide the model to bring the output vector of the task-aware label closer to the positive sample embedding vector of the corresponding behavior type, while pushing it further away to the negative sample embedding vector that does not belong to that behavior type.
[0059] The auxiliary contrastive loss can employ an information-noise contrastive estimation loss function. Its core idea is to maximize the similarity between the output vector and the positive example embedding vector, while minimizing the similarity between the output vector and the negative example embedding vector. In some embodiments, the total loss can be denoted as: ; in, Indicates the total loss. Indicates the weighted predicted loss. Represents the sorting loss. Indicates auxiliary contrast loss. Indicates the weight.
[0060] In some embodiments, the recommendation model in this specification may employ a two-stage training strategy. In the first stage of pre-training, historical user interaction data from multiple scenarios is used for basic training with generation loss as the optimization objective. This stage does not require the introduction of multi-task perception mechanisms or ranking processes for auxiliary training. Its aim is to enable the model to quickly learn basic sequence generation capabilities and general user-item interaction patterns through rich cross-scenario data. After pre-training is completed, the second stage of joint optimization is initiated. This involves using data from a single scenario to execute the processes described in steps S102 to S112 (i.e., the recommendation model in steps S102 to S112 is the model obtained after the first stage of training). Based on the pre-trained model, multi-task perception labeling, weighted prediction loss for multiple behavior types, and ranking loss assisted by the ranking module are further introduced to optimize the parameters of the recommendation model, thereby effectively improving the accuracy of multi-behavior prediction and comprehensive ranking capabilities of the model in specific scenarios.
[0061] Specifically, the recommendation model can be obtained by pre-training a baseline model using second training samples from multiple recommendation scenarios. The baseline model refers to the initial neural network architecture, untrained with recommendation business data before multi-scenario pre-training and specific scenario fine-tuning, serving as the network skeleton and parameter starting point for all subsequent training stages. The second training samples may include user profile features, third-party user historical interaction sequences, and sample semantic identifier sequences of the next interactive item from the third-party user historical interaction sequences. The pre-training process can be implemented as follows: inputting the second training samples into the baseline model to obtain the predicted semantic identifier sequence of the next interactive item output by the baseline model; determining the generation loss of the baseline model based on the predicted semantic identifier sequence of the next interactive item output by the baseline model and the sample semantic identifier sequences included in the second training samples; adjusting the parameters of the baseline model based on the generation loss of the baseline model to obtain the recommendation model.
[0062] After training, the recommendation model can be used for online inference. In the generative retrieval inference stage of a recommendation system, the model typically employs a beam search strategy to generate semantic tag sequences for candidate items hierarchically. However, traditional beam search maintains a key-value (KV) cache independently for each candidate path, leading to repeated storage and computation of KV vectors for paths with the same prefix. As the number of candidate paths increases, memory usage and computational overhead grow dramatically, making it difficult to meet the stringent real-time requirements of recommendation systems.
[0063] To address the aforementioned issues, this specification proposes an autoregressive decoding method based on a tree-structured topology. Specifically, it involves obtaining the target user's second-user historical interaction sequence, encoding this sequence using an encoder in a trained recommendation model to obtain a second-user representation, and then performing autoregressive decoding using a trained decoder. The autoregressive decoding process includes: obtaining the key-value vectors corresponding to each of the currently generated candidate paths and their position information within the decoding tree; constructing a tree-structured attention mask based on the position information, where the semantic identifier of any candidate path is visible to its ancestor nodes and itself within the same candidate path, but invisible to semantic identifiers in different candidate paths; and then, based on the key-value vectors... Attention is calculated using vectors and tree-structured attention masks to obtain candidate semantic identifiers and their predicted probabilities for the next step. Candidate semantic identifiers obtained from different candidate paths are concatenated along the sequence dimension to form a candidate semantic identifier sequence. Based on the predicted probabilities of each candidate semantic identifier, the candidate paths with the highest scores are retained. A tree-structured topology is used to maintain a key-value cache, where only one copy of the key-value vector corresponding to the same ancestor prefix is stored, and multiple candidate paths under that ancestor prefix share the cache through index mapping. As the decoding steps increase, the key-value vector corresponding to the newly generated semantic identifier is appended to the cache of its corresponding path until a complete semantic identifier sequence is generated.
[0064] In the above process, the tree-structured attention mask ensures that each candidate path, when calculating attention, only focuses on the path from the root node to the current node (i.e., ancestor nodes and itself), while masking the semantic identifiers on other branch paths, thus guaranteeing the independence and correctness of each branch generation. For example, if path A branches into A1 and A2, and path B branches into B1 and B2, then path A1 can only focus on the root node, A, and A1, and cannot focus on B and its branches.
[0065] Regarding key-value cache maintenance, all candidate paths share the same key-value cache for the same decoding tree. When multiple candidate paths have the same ancestor prefix, the key-value vector corresponding to that prefix is stored only once, and all paths refer to it through index pointers. For example, candidate paths A1 and A2 share a prefix (root node and semantic identifier A), so the key-value vector of that prefix only needs to be stored once. As the decoding process progresses, newly generated key-value vectors are appended to the end of the cache for their respective paths without affecting other branches. This approach effectively reduces storage overhead.
[0066] When retaining candidate paths, the recommendation model can calculate the cumulative score of all candidate paths (usually the sum of the logarithms of the predicted probabilities at each level) at each decoding step, and retain the K highest-scoring paths (K being the bundle width), discarding lower-scoring paths and their branches. As the decoding process progresses, the decoding tree continuously grows and is pruned until all retained paths generate a complete hierarchical semantic tag sequence. The recommendation model can then select several paths with the highest cumulative scores from the surviving paths, map their corresponding semantic tag sequences back to item tags, and use this as a set of candidate items to recommend to the target user. Through this tree-like topology autoregressive decoding method, the recommendation model can reduce the computational and storage overhead of the inference phase while ensuring the quality of candidate item recall.
[0067] See Figure 4 The embodiments of this specification also provide a recommended method, which further includes: Step S202: Obtain the second user historical interaction sequence of the target user, and encode the second user historical interaction sequence through the encoder in the trained recommendation model to obtain the second user representation; the trained recommendation model is trained based on the method described in any of the foregoing embodiments; Step S204: Perform autoregressive decoding using the trained decoder, and perform the following operations during autoregressive decoding: Step S2040: Obtain the key-value vectors corresponding to each of the currently generated candidate paths, and obtain the position information of each candidate path in the decoding tree; Step S2042: Construct a tree-like attention mask based on the location information; in the tree-like attention mask, the candidate semantic identifier in any candidate path is visible to the ancestor nodes in the same candidate path and to itself, but is not visible to the semantic identifiers in different candidate paths. Step S2044: Perform attention calculation based on the key-value vector and the tree-structured attention mask to obtain the candidate semantic identifiers and their predicted probabilities for the next step; Step S2046: Concatenate the candidate semantic identifiers obtained from different candidate paths along the sequence dimension to form a candidate semantic identifier sequence; Step S2048: Based on the predicted probabilities of each candidate semantic identifier, retain the candidate paths with the highest scores; and maintain the key-value cache using a tree-like topology structure. The key-value vector corresponding to the same ancestor prefix is stored only once in the key-value cache and shared by multiple candidate paths under that ancestor prefix through index mapping; as the decoding steps increase, the key-value vector corresponding to the newly generated semantic identifier is appended to the cache of its path until a complete semantic identifier sequence is generated. Step S206: Based on the semantic identifier sequence, determine the items to recommend to the target user, and send the information of the determined items to the target user.
[0068] Figure 5 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 5 As shown, device 300 mainly consists of a communication interface 301, a user interface 302, a processor 303, and a data storage 304. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 305. The communication interface 301 enables device 300 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 301 may include a chipset and antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 301 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 301 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 301 may also include multiple physical communication interfaces, such as Wi-Fi, Bluetooth, and wide-area wireless interfaces.
[0069] User interface 302 includes receiving user input and providing output to the user. Therefore, user interface 302 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 302 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 302 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 300 may support remote access from other devices via communication interface 301 or another physical interface (not shown). User interface 302 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 302 may also be configured as a display device for rendering or displaying text fragments.
[0070] Processor 303 may include one or more general-purpose processors and / or special-purpose processors.
[0071] Data storage 304 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 303. Data storage 304 may include removable and non-removable components.
[0072] Processor 303 is capable of executing program instructions 309 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 304 to perform the various functions described herein. Data storage 304 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 300, enable device 300 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 309 by processor 303 may result in processor 303 using data 306.
[0073] For example, program instructions 309 may include an operating system 311 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 300 and one or more applications 310 (e.g., a browser, social application, or game application). Similarly, data 306 may include operating system data 308 and application data 307. Operating system data 308 is primarily accessible to the operating system 311, while application data 307 is primarily accessible to one or more applications 310. Application data 307 may reside in a file system visible or hidden from the user of device 300.
[0074] Application 310 can communicate with operating system 311 through one or more application programming interfaces (APIs). These APIs help application 310 read and / or write application data 307, transmit or receive information via communication interface 301, receive or display information on user interface 302, etc.
[0075] In some terminology, application 310 may be simply referred to as "app". Furthermore, application 310 can be downloaded to device 300 through one or more online app stores or app markets. However, applications can also be installed on device 300 in other ways, such as through a web browser or a physical interface on device 300 (e.g., a USB port).
[0076] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0077] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0078] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0079] What those skilled in the art will understand is: In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.
[0080] In this specification, “a,” “an,” and “the” do not specifically refer to the singular, but may also include the plural.
[0081] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0082] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0083] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0084] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.
[0085] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.
Claims
1. A method for training a recommendation model, the recommendation model comprising an encoder, a decoder, and a ranking module; The method includes: Obtain a first training sample, which includes: a first user history interaction sequence of the target user, and multiple sample semantic identifier sequences corresponding to the next interactive item in the first user history interaction sequence; the multiple sample semantic identifier sequences correspond to multiple preset behavior types respectively; The encoder encodes the first user's historical interaction sequence to obtain a first user representation; The task-aware labels corresponding to the various behavior types are determined, and the semantic identifier sequences of the multiple samples are concatenated with the corresponding task-aware labels to obtain the input sequence; the task-aware labels are learnable vectors used to indicate the task type of the prediction task. The input sequence is decoded by the decoder. Based on the first user representation and the hidden state corresponding to each behavior type output by the decoder during the decoding process, the semantic identifier sequence of the user's next interactive item is independently predicted for each behavior type. The prediction loss under each behavior type is determined based on the predicted semantic identifier sequence and the sample semantic identifier sequence corresponding to each behavior type. The prediction loss under the corresponding behavior type is weighted according to the importance weight corresponding to each behavior type to obtain the weighted prediction loss. The first user representation is concatenated with the hidden state corresponding to each behavior type to obtain the user behavior intent vector corresponding to each behavior type. The user behavior intent vector corresponding to each behavior type is input into the sorting module to obtain the preference prediction score of the predicted semantic identifier sequence under each behavior type. The sorting loss is determined based on the preference prediction score under each behavior type. The total loss is determined based on the weighted prediction loss and the ranking loss, and the parameters of the recommendation model are optimized based on the total loss.
2. The method according to claim 1, wherein the encoder comprises a multilayer perceptron; the step of encoding the first user's historical interaction sequence through the encoder to obtain a first user representation comprises: The semantic identifier embedding of each item in the first user history interaction sequence is combined with the corresponding behavior type information and location information to obtain the coded representation of the item; the semantic identifier embedding is obtained by embedding the semantic identifier sequence of the item, the behavior type information is used to uniquely identify each behavior type, and the location information is used to indicate the position of the item in the first user history interaction sequence; The sequence, which includes the encoded representations of each item, is subjected to positional encoding and linear projection processing to obtain a memory representation; The user profile features of the target user are mapped by the multilayer perceptron to obtain a user profile representation vector, and the user profile representation vector is added as a prefix to the beginning of the memory representation to obtain the first user representation.
3. The method according to claim 2, wherein the semantic identifier embedding is obtained through the following means: Obtain the multimodal features of the item, including the item's textual metadata and visual features; The multimodal features are input into a multimodal encoder to obtain the multimodal embedding vector of the item; The multimodal embedding vector is subjected to residual quantization encoding to generate a semantic identifier sequence for the item; the semantic identifier sequence includes semantic identifiers at multiple levels. The semantic identifiers at each level in the semantic identifier sequence are embedded to obtain the semantic identifier embedding.
4. The method according to claim 1, wherein concatenating the plurality of sample semantic identifier sequences with corresponding task-aware tags to obtain the input sequence comprises: Each of the task-aware tags is appended as a global prefix to the beginning of the input sequence; The decoder includes an attention layer, and the sample semantic identifier sequence includes multiple levels; Decoding the input sequence using a decoder includes: A custom causal mask is applied to the input sequence, and an attention mechanism is used in the attention layer to decode the input sequence with the custom causal mask applied. The custom causal mask is used for: Within the semantic identifier sequence of samples corresponding to the same behavior type, each level of semantic identifier is constrained to be visible only to itself and the semantic identifiers of the preceding levels, and not to the semantic identifiers of the following levels; and The semantic identifiers of samples corresponding to different behavior types are constrained to be mutually invisible.
5. The method according to claim 4, wherein the multiple behavior types include click behavior, add-to-cart behavior, and purchase behavior; the custom causal mask is further used to constrain: The click task perception markers in the sample semantic identifier sequence only focus on the click task perception markers themselves, and do not focus on the add-to-cart task perception markers and purchase task perception markers; The add-to-cart task awareness marker only focuses on the click task awareness marker and the add-to-cart task awareness marker, and does not focus on the purchase task awareness marker; Purchase Task Awareness Markers: Follow, click, add to cart, and purchase Task Awareness Markers.
6. The method according to claim 1, wherein determining the total loss based on the weighted prediction loss and the ranking loss comprises: For each behavior type, obtain the output vector of the task-aware tag in the decoder; Using the embedding vectors of positive sample items with corresponding behavior types in the first training sample as positive examples and the embedding vectors of negative sample items without corresponding behavior types in the first training sample as negative examples, the output vector is subjected to comparative learning to obtain auxiliary comparative loss. The total loss is determined based on the weighted prediction loss, the ranking loss, and the auxiliary comparison loss.
7. The method according to claim 1, wherein the decoder comprises a shared expert network and multiple routing expert networks; During the decoding process, for the current input unit, the matching weight between the input unit and each routing expert network is calculated through the routing network. Several routing expert networks are activated based on the matching, and the output of the input unit after passing through the feedforward network layer is determined based on the output of the activated routing expert network and the output of the shared expert network. The input unit is a semantic identifier or a task-aware tag. in, The shared expert network is used to capture general recommendation patterns, and the multiple routing expert networks are used to differentiate the input features of different semantic subspaces or different user interest patterns.
8. The method according to claim 1, wherein the recommendation model is a pre-trained model obtained by pre-training a benchmark model based on second training samples of multiple recommendation scenarios, wherein the second training samples include user profile features, a third user historical interaction sequence, and a sample semantic identifier sequence of the next interactive item in the third user historical interaction sequence; and the first training samples include training samples of a specific recommendation scenario. The pre-training process includes: Input the second training sample into the benchmark model to obtain the predicted semantic identifier sequence of the next interactive item output by the benchmark model; Based on the predicted semantic identifier sequence of the next interactive item output by the benchmark model and the sample semantic identifier sequence included in the second training sample, the generation loss of the benchmark model is determined. The parameters of the baseline model are adjusted based on the generation loss of the baseline model to obtain the recommendation model.
9. The method according to claim 1, wherein the sorting module comprises: The module includes a target attention submodule and a multi-target ranking submodule based on progressive hierarchical extraction. The target attention submodule adopts a cross-attention mechanism, using the semantic ID representation of the candidate item as the query vector and the encoded representation of the first user's historical interaction sequence as the key vector and value vector. By calculating attention weights, it dynamically locates the interaction segments related to the current candidate item from the first user's historical interaction sequence and obtains the target attention output. The multi-objective ranking submodule includes a shared expert network, a task-specific expert network, and a gating network; wherein: The shared expert network learns common features among multiple ranking targets based on multi-source input features; the multi-source input features include user information, the semantic ID representation, the target attention output, and the decoder representation; The task-specific expert network learns personalized features for each ranking target based on the multi-source input features; The gating network dynamically allocates the weights of the shared expert network and the task-specific expert network based on the input samples, and extracts high-order features through layer-by-layer routing to output multi-objective ranking results.
10. A recommended method, the method further comprising: The second user's historical interaction sequence is obtained, and the second user's historical interaction sequence is encoded by the encoder in the trained recommendation model to obtain the second user representation; the trained recommendation model is trained based on the method described in any one of claims 1 to 9. Autoregressive decoding is performed using the trained decoder, and the following operations are performed during the autoregressive decoding: Obtain the key-value vectors corresponding to each of the currently generated candidate paths, and obtain the position information of each candidate path in the decoding tree; Based on the location information, a tree-like attention mask is constructed; in the tree-like attention mask, the candidate semantic identifier in any candidate path is visible to the ancestor nodes in the same candidate path and to itself, but is not visible to the semantic identifiers in different candidate paths; Attention is calculated based on the key-value vector and the tree-structured attention mask to obtain the candidate semantic identifiers and their predicted probabilities for the next step. The candidate semantic identifiers obtained from different candidate paths are concatenated along the sequence dimension to form a candidate semantic identifier sequence; Based on the predicted probability of each candidate semantic identifier, the top-scoring candidate paths are retained; and a tree-like topology structure is used to maintain the key-value cache. The key-value vector corresponding to the same ancestor prefix is stored only once in the key-value cache and shared by multiple candidate paths under that ancestor prefix through index mapping. As the decoding steps increase, the key-value vector corresponding to the newly generated semantic identifier is appended to the cache of its path until a complete semantic identifier sequence is generated. Based on the semantic identifier sequence, items recommended to the target user are determined, and information about the determined items is sent to the target user.
11. An electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor implements the steps of the method as described in any one of claims 1 to 10 by executing the executable instructions.
12. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1 to 10.
13. A computer program product comprising computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1 to 10.
