Cross-domain recommendation method and system fusing large language model and hierarchical contrast learning
By constructing domain-specific and globally shared graph structures, combined with large language models and hierarchical contrastive learning, the problems of cross-domain preference interference and semantic-structural misalignment in cross-domain recommendation are solved, achieving accurate transfer of cross-domain knowledge and feature fusion, and improving the accuracy and robustness of recommendations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-20
- Publication Date
- 2026-04-10
AI Technical Summary
Existing cross-domain recommendation methods suffer from cross-domain preference interference, semantic-structural misalignment, and insufficient model generalization ability, resulting in poor recommendation performance.
By employing a method that integrates large language models with hierarchical contrastive learning, structural features are extracted by constructing domain-specific and globally shared graph structures. Two-stage contrastive learning and adaptive fusion are then performed to dynamically adjust feature weights, achieving efficient separation and alignment of globally shared knowledge and domain-specific knowledge.
It improves the accuracy and robustness of cross-domain recommendations, maintains stable and accurate recommendation results in complex scenarios, adapts to different data conditions and business scenarios, and enhances the interpretability of recommendation results.
Smart Images

Figure CN121834049A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a cross-domain recommendation method and system that integrates large language models and hierarchical contrastive learning. Background Technology
[0002] Recommender systems, as a core technology for alleviating information overload and improving user experience, have been widely applied in e-commerce, content platforms, and other scenarios. With the diversification of internet services, user behavior data is often scattered across multiple related but different domains (such as electronics, books, and cosmetics on shopping platforms). How to effectively utilize this multi-domain data to enhance recommendation performance has become a key research direction for recommender systems, and related technologies have mainly evolved into the following three categories: The first category is single-domain sequence recommendation methods. These methods, such as GRU4Rec and SASRec, focus on modeling the dynamic sequence of user behavior within a single domain and excel at capturing users' temporal preferences within that domain. However, their models are completely limited to a single domain and cannot utilize the rich interaction information of users in other domains, forming "knowledge silos." Their performance is limited when data is sparse or cross-domain recommendations are required.
[0003] The second category comprises cross-domain sequence recommendation methods. To overcome the limitations of single-domain approaches, researchers have proposed methods such as GA-DTCDR, C2DSR, and TriCDR. These methods aim to transfer user preferences from the source domain to the target domain by constructing cross-domain graph structures, designing cross-domain attention mechanisms, or implementing contrastive learning. Although some progress has been made, most of these methods adopt a holistic fusion approach, which globally mixes and transmits information from different domains. This fails to adequately decouple and distinguish between globally shared knowledge (such as the general user preference for high cost-effectiveness) and domain-specific knowledge (such as focusing on ingredient safety in the beauty field and professional performance in the sports field). This coarse-grained fusion is prone to cross-domain preference interference, where inconsistent behavioral patterns of overlapping users in different domains interfere with each other, ultimately impairing recommendation accuracy.
[0004] The third category comprises Large Language Model (LLM)-based recommendation methods. With the rise of LLM, methods such as SAID and LLM-ESR have emerged. These methods leverage the powerful semantic understanding and generation capabilities of LLM to transform user history or item information into high-quality semantic embeddings, significantly improving the richness and personalization of feature representation. However, these methods typically overlook the inherent structural dependencies in the user-item interaction graph. A misalignment exists in the representation space between the semantic features generated by LLM and the structural features learned from the interaction graph, making direct and effective fusion difficult. This results in the model failing to fully utilize collaborative signals, affecting the stability and interpretability of the final recommendation performance.
[0005] In summary, the existing technology mainly suffers from the following three problems: 1. Cross-domain preference interference: Existing cross-domain recommendation methods mostly focus on global integration and do not fully distinguish between globally shared knowledge and domain-specific knowledge. This leads to inconsistent behavior of overlapping users in different domains, which interferes with the recommendation effect.
[0006] 2. Semantic-structural misalignment: The semantic features generated based on LLM are difficult to align with the structural dependencies of the user-item graph, affecting the effectiveness of feature fusion.
[0007] 3. Insufficient model generalization ability: When faced with challenging scenarios such as sparse data and cold-start users or items, existing methods struggle to balance cross-domain knowledge transfer and domain-specific feature capture, resulting in limited recommendation accuracy and model robustness. Summary of the Invention
[0008] This invention addresses three core shortcomings of existing multi-domain and cross-domain recommendation technologies: cross-domain preference interference, semantic-structural feature misalignment, and insufficient model generalization ability. It proposes a cross-domain recommendation method and system that integrates a large language model and hierarchical contrastive learning. Through a four-step core process of hierarchical decoupling modeling, LLM feature enhancement, hierarchical contrastive learning, and two-stage adaptive fusion, it achieves efficient separation, alignment, and integration of globally shared knowledge and domain-specific knowledge, ultimately improving the accuracy and robustness of cross-domain recommendations.
[0009] To achieve the above objectives, the present invention adopts the following technical solution: This invention proposes a cross-domain recommendation method that integrates a large language model with hierarchical contrastive learning, comprising: Step 1: Construct a domain-specific graph structure and a globally shared graph structure for the user-item interaction data; extract domain-specific structural features from the domain-specific graph structure through domain-specific graph convolution operation; extract globally shared structural features from the domain-shared graph structure through domain-shared graph convolution operation; Step 2: Generate user semantic vectors and item semantic vectors as semantic features based on the large language model; dynamically calculate and adjust the weights of long-term preference components and short-term preference components in the user semantic vectors according to the user's long-term and short-term interaction frequencies; Step 3: Based on the domain-specific structural features extracted in the previous steps and the generated semantic features, perform a two-stage comparative learning process that includes random edge dropping and noise injection to obtain aligned semantic and structural features; Step 4: In the first stage, based on the user's interaction frequency in the target subdomain and the information gain of semantic features, the aligned semantic features and the domain-specific structural features are dynamically fused to obtain the first fused feature; in the second stage, based on whether the recommendation task type is cross-domain migration or intra-domain recommendation, the first fused feature and the globally shared structural features are dynamically fused to generate the second fused feature, and then the final recommendation feature vector is obtained. Step 5: Based on the final recommended feature vector, predict user-item interactions and construct a total loss function that includes both contrastive learning loss and prediction loss to optimize all model parameters.
[0010] Furthermore, the domain-specific graph convolution operation described in step 1 is used to update the user representation, and its formula is: in This indicates that user u is in the domain d. The updated hidden state of the layer contains the unique interactive features specific to that domain. Indicates the activation function; The domain d represents the first... The domain-specific transformation matrix of the layer; Let represent the set of neighboring nodes of user u in domain d, where the neighboring nodes are the items that the user has interacted with in domain d; λ is the regularization term; Indicates that the neighboring node v is at the th The original hidden state of the layer.
[0011] Furthermore, the domain-specific graph convolution operation described in step 1 is also used to update the item representation, and its formula is: in Indicates that item i is in the domain d. The updated hidden state of the layer contains the unique interactive features specific to that domain. Let d represent the set of neighboring nodes of item i within the domain d. The neighboring nodes are users who have similar interaction behaviors with the item. Indicates that the neighboring node j is at the th... The original hidden state of the layer.
[0012] Furthermore, the global shared graph convolution operation described in step 1 is used to update the user representation, and its formula is: in Indicates user u's The layers share a hidden state, which contains common features that are transferable across domains; Indicates the first The layer shares a domain transformation matrix; This represents the set of neighboring nodes of user u across all domains.
[0013] Furthermore, the global shared graph convolution operation described in step 1 is also used to update the item representation, and its formula is: in Indicates the i-th item The layers share a hidden state, which contains common features that are transferable across domains; Let i represent the set of neighborhood nodes of item i in all domains.
[0014] Furthermore, the logic for dynamically adjusting the user semantic vector weights in step 2 includes: Based on the user's long-term interaction frequency and short-term interaction frequency, the long-term preference weight α(t) and the short-term preference weight β(t) are dynamically calculated. The user semantic vector Generate using the following formula: in , , These represent the long-term preference vector, short-term preference vector, and core demand vector of user u, respectively.
[0015] Furthermore, it also includes user semantic vectors. Post-processing operations: in This indicates the PCA dimensionality reduction operation. This represents the L2-normalized final user semantic vector.
[0016] Furthermore, the item vector mentioned in step 2 The definition (LLM semantic embedding) is as follows: ITEM_TITLE, MAIN_CATEGORY, KEY_FEATURES, and TARGET_USER_GROUP represent the title information, main category information, key attribute information, and target user group information of the target item, respectively.
[0017] Furthermore, it also includes calculating user-item pairs. The similarity, and use it as a user-item pair The semantic feature vector.
[0018] Furthermore, the loss function for the first stage of contrastive learning in step 3 is: Where M represents the number of positive samples, i.e., the total number of user-item interaction pairs; R represents the set of user-item interactions; Represents user-item pairs Domain-specific structural feature vectors Represents user-item pairs semantic feature vectors, This is the feature vector obtained after randomly discarding edges from the structural features; Indicates the temperature coefficient; This represents the cosine similarity function.
[0019] Furthermore, the loss function for the second stage of contrastive learning in step 3 is: in, This indicates the optimized user-item pairs after the first phase of comparative learning. semantic feature vectors, This represents the feature vector after noise injection.
[0020] Furthermore, the specific method of the first stage of fusion in step 4 is as follows: in, This represents the user-item pairs after the first phase of integration. eigenvectors; This is the normalized user semantic feature vector; Represents user-item pairs Domain-specific structural feature vectors; and These are the weighting coefficients. The specific value is adjusted according to the change in information gain of semantic features. The specific value is adjusted according to the interaction frequency of the target subdomain.
[0021] Furthermore, the specific method of the second-stage fusion in step 4 is as follows: in, This represents the user-item pairs after the second phase of integration. eigenvectors; Represents user-item pairs The globally shared structural feature vector; γ represents the weight coefficient, and the specific value of γ is adjusted according to whether the recommendation task is cross-domain migration or intra-domain recommendation.
[0022] Furthermore, step 4 also includes... Post-processing: in This represents the user-item pairs ultimately used for recommendation ranking. eigenvectors; Represents the ReLU activation function; yes The L2 norm.
[0023] Another aspect of this invention proposes a cross-domain recommendation system that integrates a large language model with hierarchical contrastive learning, comprising: The domain decoupling feature extraction module is used to construct a domain-specific graph structure and a globally shared graph structure for user-item interaction data, respectively; extract domain-specific structural features from the domain-specific graph structure through domain-specific graph convolution operation; and extract globally shared structural features from the domain-shared graph structure through domain-shared graph convolution operation. The semantic feature generation and dynamic weighting module is used to generate user semantic vectors and item semantic vectors as semantic features based on a large language model; and dynamically calculates and adjusts the weights of long-term preference components and short-term preference components in the user semantic vectors according to the user's long-term and short-term interaction frequencies. The hierarchical contrastive learning alignment module is used to perform two-stage contrastive learning, including random edge dropping and noise injection, based on the domain-specific structural features extracted in the aforementioned steps and the generated semantic features, to obtain aligned semantic and structural features. A two-stage adaptive feature fusion module is used for: in the first stage, dynamically fusing the aligned semantic features and the domain-specific structural features based on the user's interaction frequency in the target subdomain and the information gain of the semantic features to obtain a first fused feature; in the second stage, dynamically fusing the first fused feature and the globally shared structural features based on whether the recommendation task type is cross-domain migration or intra-domain recommendation to generate a second fused feature, thereby obtaining the final recommendation feature vector. The model training and recommendation prediction module is used to predict user-item interactions based on the final recommendation feature vector, and to construct a total loss function that includes both contrastive learning loss and prediction loss to optimize all model parameters.
[0024] Compared with the prior art, the present invention has the following beneficial effects: 1. By leveraging the synergistic effect of domain-decoupled convolution, LLM feature enhancement, hierarchical contrastive learning, and two-stage adaptive fusion, this invention effectively integrates semantic and structural information and achieves accurate cross-domain knowledge transfer. Experiments on publicly available multi-domain recommendation benchmark datasets (such as the Amazon cross-domain dataset) demonstrate that this method significantly outperforms existing single-domain recommendation, cross-domain recommendation, and LLM-based recommendation baseline models in core recommendation metrics such as hit rate and normalized loss cumulative gain, showing a significant relative improvement and proving its superior comprehensive recommendation performance.
[0025] 2. This invention employs a hierarchical decoupling feature extraction method by constructing domain-specific graphs and globally shared graphs, fundamentally separating users' domain-specific preferences from cross-domain shared preferences. This mechanism ensures that inconsistent or even conflicting behavioral patterns across different domains are not confused during knowledge transfer, thereby significantly reducing the inherent preference interference problem in cross-domain recommendations. This allows the model to maintain stable and accurate recommendation results even in complex scenarios with diverse user interests and significant domain differences.
[0026] 3. To address the challenge of fusing LLM semantic features with graph structural features, this invention designs a hierarchical contrastive learning strategy that incorporates random edge dropping and noise injection. This strategy, through two-stage progressive training, precisely aligns the fine-grained semantic vectors generated by LLM to the structural feature space of the user-item interaction graph. This not only solves the semantic-structural misalignment problem but also enhances the model's robustness to data sparsity and noise through data augmentation, laying a solid foundation for subsequent feature fusion.
[0027] 4. The two-stage adaptive fusion mechanism of this invention can dynamically adjust the contribution weights of domain-specific knowledge, globally shared knowledge, and LLM semantic knowledge based on the richness of interactive data in the target domain, user activity, and specific task type (cross-domain migration or intra-domain recommendation). This dynamic balancing ability allows the model to intelligently rely on global knowledge or semantic knowledge for supplementation when facing data-sparse domains or cold-start users / items; while in data-rich scenarios, it can focus on precise domain-specific features. Thus, the model's generalization ability and robustness under different data conditions are comprehensively improved.
[0028] 5. This invention has a clear framework and a high degree of modularity. The introduction of LLM allows user and item preferences and attributes to be presented in human-understandable semantic vector form, enhancing the interpretability of recommendation results. Simultaneously, the adaptive fusion mechanism enables the system to flexibly adapt to diverse business scenarios (such as different domain combinations and different cold start intensities), demonstrating good practicality and flexibility. Attached Figure Description
[0029] Figure 1A basic flowchart of a cross-domain recommendation method that integrates a large language model and hierarchical contrastive learning, provided in an embodiment of the present invention; Figure 2 A schematic diagram of the model framework for a cross-domain recommendation method that integrates a large language model and hierarchical contrastive learning, provided in an embodiment of the present invention; Figure 3 The experimental results are shown in the figure provided in the embodiment of the present invention; Figure 4 This is a schematic diagram of the architecture of a cross-domain recommendation system that integrates a large language model and hierarchical contrastive learning, provided as an embodiment of the present invention. Detailed Implementation
[0030] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments: like Figure 1 As shown, a cross-domain recommendation method integrating large language models and hierarchical contrastive learning includes: S101: Construct a domain-specific graph structure and a globally shared graph structure for user-item interaction data respectively; extract domain-specific structural features from the domain-specific graph structure through domain-specific graph convolution operation; extract globally shared structural features from the domain-shared graph structure through domain-shared graph convolution operation; S102: Generate user semantic vectors and item semantic vectors as semantic features based on a large language model; dynamically calculate and adjust the weights of long-term preference components and short-term preference components in the user semantic vectors according to the user's long-term and short-term interaction frequencies; S103: Based on the domain-specific structural features extracted in the aforementioned steps and the generated semantic features, perform a two-stage comparative learning process that includes random edge dropping and noise injection to obtain aligned semantic and structural features; S104: In the first stage, based on the user's interaction frequency in the target subdomain and the information gain of semantic features, the aligned semantic features and the domain-specific structural features are dynamically fused to obtain the first fused feature; in the second stage, based on whether the recommendation task type is cross-domain migration or intra-domain recommendation, the first fused feature and the globally shared structural features are dynamically fused to generate the second fused feature, thereby obtaining the final recommendation feature vector. S105: Based on the final recommended feature vector, predict user-item interactions and construct a total loss function that includes both contrastive learning loss and prediction loss to optimize all model parameters.
[0031] The method specifically includes: 1. Overall Architecture Design The core structure of the method model framework consists of four layers. These layers do not operate independently but rather form a complete technical chain through collaborative scheduling: "knowledge decoupling - feature enhancement - alignment optimization - fusion output." This ensures that global and domain-specific knowledge are neither confused nor mutually exclusive throughout the entire process. Figure 2 As shown. The first layer is a domain decoupling layer, which uses two types of graph convolution operations—domain-specific and domain-shared—to capture domain-specific interaction features (such as users' preferences for "exercise comfort" in the sports field and their focus on "ingredient safety" in the beauty field) and cross-domain common features (such as attributes that users generally value, such as "cost-effectiveness" and "reputation"), thereby reducing mutual interference between cross-domain signals from the source. The second layer is an LLM personalized adaptation layer, which relies on the strong semantic understanding capabilities of large language models (such as ChatGLM2-6B) to generate fine-grained semantic vectors for users and items through structured prompting engineering, while also adapting to real-time user feedback. The interaction behavior dynamically adjusts preference weights to adapt to changes in user interests. The third layer is a hierarchical contrastive learning layer, which combines random edge dropout and noise injection as data augmentation techniques. It performs comparative training on the semantic features generated by LLM and the structural features output by graph convolution in two stages, gradually achieving accurate alignment of the two types of features and solving the semantic-structural misalignment problem. The fourth layer is a two-stage adaptive fusion layer. Through a dynamic weight adjustment mechanism, it first balances the contributions of LLM semantic features and subdomain structural features, and then integrates subdomain features with globally shared features, finally outputting a feature vector that can be directly used for recommendation ranking. This layer mainly undertakes the collaborative scheduling logic of each functional layer, ensuring that the features output by the preceding layer can flow to the subsequent layers along the optimal path, avoiding information loss during feature transmission.
[0032] 2. Domain-decoupled convolution 2.1 Domain-Specific Graph Convolution This invention captures unique user-item interaction patterns across different domains through domain-specific graph convolution. Specifically, it constructs a domain-specific graph structure for each domain and aggregates user-item neighborhood information within that domain using dedicated graph convolution operations, generating a domain-specific embedding that contains only features specific to the current domain. In its implementation, this operation strictly limits the scope of neighborhood information aggregation, extracting features only from user or item interaction nodes within the current domain. For example, the set of neighborhood nodes for user u in the sports domain. Only sports equipment items clicked and purchased within the sports domain are included, excluding skincare product nodes interacted with within the beauty domain, thus fundamentally isolating cross-domain preference interference. Simultaneously, to prevent overfitting when learning domain-specific features, a regularization term λ (within a range of...) is introduced during graph convolution calculation. This regularization term not only restricts the weight matrix, but also... The parameter size is stable, and the parameter update direction is stable in each iteration, ensuring that the model maintains parameter stability while capturing domain characteristics.
[0033] User domain specificity representation update: Item domain specificity representation updated: in, This represents the domain-specific transformation matrix of domain d at layer l. Its parameters are optimized individually based on the distribution of interaction data within that domain, such as in the sports domain. The model will focus on learning features such as "type of exercise" and "applicable scenarios", while the beauty industry will focus on features such as "ingredient type" and "skin type compatibility"; λ is the regularization term, and its value is determined through cross-validation to balance the model's fitting ability and generalization ability. , These represent the hidden states of user u and item i in the (l+1)th layer of domain d after the update, respectively, and include the exclusive interaction features within this domain; , Let represent the sets of neighborhood nodes of user u and item i in domain d, respectively. The user neighborhood consists of the items that the user has interacted with in domain d, and the item neighborhood consists of users who have similar interaction behaviors with the item. δ represents the activation function, which is ReLU by default. It enhances the model's ability to express nonlinear features by filtering negative feature values. , These represent the original hidden states of neighboring nodes v (items in the user's neighborhood) and j (users in the item's neighborhood) at layer l, respectively, providing neighborhood information support for the feature update of the current node.
[0034] 2.2 Domain-Shared Graph Convolution To facilitate the effective transfer of cross-domain knowledge and alleviate data sparsity issues in certain domains (such as niche domains), this invention constructs a global heterogeneous graph (global shared graph structure). This integrates user-item interaction data from all domains into a single graph structure. Cross-domain interaction information is aggregated through domain-shared graph convolution operations to generate shared knowledge embeddings with cross-domain transferability. The core logic of this operation is to extract common features of users and items across different domains. For example, in sports, electronics, and beauty, user preferences for items with "high ratings" and "high sales" are universal. Attributes such as "brand awareness" and "after-sales service" also play a role in multiple domains. These common features can serve as the core carriers of cross-domain knowledge, providing feature supplementation for data-sparse domains. Similar to domain-specific graph convolution, domain-shared graph convolution also introduces a regularization term λ to avoid parameter redundancy and overfitting problems caused by aggregating data from multiple domains.
[0035] User domain sharing indicates an update: Item domain sharing notification updated: in, This represents the domain-shared transformation matrix of the l-th layer, whose parameters are jointly optimized on the interaction data of all domains, focusing on learning cross-domain common features; , These represent the sets of neighborhood nodes for user u and item i across all domains, covering the user / item's interaction nodes in all domains such as sports, electronics, and beauty. , Let represent the domain-shared hidden states of user u and item i at layer l+1, respectively, containing common features that are transferable across domains; the remaining symbols (δ, λ, ... (etc.) Consistent with domain-specific graph convolution, ensuring that the parameter definitions and computational logic of the two-layer operations are unified.
[0036] 3. LLM-based Personalized Domain Adaptation Mechanism 3.1 User Semantic Vector Generation and Dynamic Capture of Personalized User Preferences This invention designs a personalized domain-adaptive mechanism based on a large language model (such as ChatGLM2-6B). Through structured prompting engineering and dynamic weight adjustment, it generates user semantic vectors that are both fine-grained and timely. Specifically, it first constructs a structured prompt template that includes users' long-term preferences, recent trends, and core needs. For example, it explicitly guides the LLM to summarize "long-term core themes of interest" (such as "professional basketball equipment") based on users' interaction data over the past 6 months, "recent interest trends" (such as "lightweight basketball shoes") based on interactions over the past 2 weeks, and "core needs" (such as "breathable and durable") based on users' historical feedback. The LLM generates a 4096-dimensional original user semantic vector based on this template, which can fully cover the semantic details of user preferences. To adapt to the dynamic changes in user interests, this invention designs a dynamic weight adjustment logic based on interaction frequency: if the user's interaction frequency in the recent period (such as within 2 weeks) is significantly higher than that in the long term (such as within 6 months), the weight of the short-term preference vector is increased. Conversely, the weights of the long-term preference vector are increased. At the same time, a certain weight is reserved for the core requirement vector. This ensures that users' fundamental needs (such as the requirement for "cost-effectiveness") are not overshadowed by short-term fluctuations in interest. Since the 4096-dimensional vector contains many redundant features and has high computational cost, it is compressed to 256 dimensions using PCA dimensionality reduction. This reduces computational complexity while preserving the core semantic information of the vector through principal component analysis. Finally, L2 normalization is performed to ensure that the vectors of different users are on the same scale, avoiding the impact of vector magnitude differences on the fairness of subsequent similarity calculations.
[0037] Original user semantic vector definition (integrating multi-dimensional preferences): Dynamic weight update logic (based on interaction frequency): Vector post-processing (dimensionality reduction + normalization): in, This represents the 4096-dimensional original user vector generated by LLM, which contains semantic information about users' long-term preferences, short-term trends, and core needs. , Let each represent a dynamic weight based on the user's behavior at time t, satisfying... The long-term interaction frequency refers to the number of interactions a user has made in the past 6 months, the short-term interaction frequency refers to the number of interactions in the past 2 weeks, and the total interaction frequency is the sum of the two. , , These represent user long-term preferences, short-term trends, and core demand vectors, all generated by LLM based on prompt templates for the corresponding dimensions. This indicates that PCA dimensionality reduction operation compresses a 4096-dimensional vector to 256 dimensions through principal component analysis, retaining more than 95% of the feature variance; This represents the final user semantic vector after L2 normalization, ensuring that the L2 norm of different user vectors is 1, and can be directly used for similarity comparison.
[0038] 3.2 Item semantic vector generation and similarity calculation To achieve semantic matching between users and items, this invention guides LLM (Liquidity Management Model) through prompting engineering to generate semantic vectors containing key item attributes. It then calculates the matching degree between users and items based on cosine similarity, providing a preliminary basis for subsequent recommendation filtering. The generation of item vectors relies on structured prompt templates containing item titles, main categories, subcategories, core features, and target user groups. For example, for "a certain brand of moisturizing face cream," the prompt template guides LLM to summarize key information such as "main category is beauty, subcategory is facial care," "core features are 'hyaluronic acid ingredient, long-lasting moisturizing'," and "target user group is 'dry skin type, women aged 25-35'." Based on this information, LLM generates a 4096-dimensional item semantic vector with the same dimension as the user vector. This vector accurately reflects the attribute characteristics and target audience of an item. In calculating the matching degree between users and items, a cosine similarity function is used, which calculates the user's normalized semantic vector. With item semantic vector The cosine of the angle between the two items measures their semantic similarity. A value closer to 1 indicates a better match between the item's attributes and the user's preferences, while a value closer to 0 indicates a lower match. This step allows for the initial screening of items with high match rates, laying the foundation for accurate ranking after fusing structural features.
[0039] Item semantic vector definition (LLM semantic embedding): ITEM_TITLE, MAIN_CATEGORY, KEY_FEATURES, and TARGET_USER_GROUP represent the title information, main category information, key attribute information, and target user group information of the target item, respectively.
[0040] User-item similarity calculation (cosine similarity): in, This represents the embedding generation function of the large language model, specifically the output of the last hidden layer of the ChatGLM2-6B model, ensuring that the generated vectors have strong semantic expressive power. This indicates the item vector generation hint template, defined as: "Summarize the item ITEM_TITLE in TARGET_DOMAIN. Type: MAIN_CATEGORY (sub-type: SUB_CATEGORY); Creator:SOURCE. Content focuses on THEME_OVERVIEW with key features KEY_FEATURES. Suitable for TARGET_USER_GROUPneedingPREFERENCE_FEATURES(eg,EXAMPLES)." Template details can be adjusted according to item attributes in different domains. This represents the cosine similarity function, with a value range of [0,1]. The larger the value, the higher the matching degree between user preferences and item attributes. This represents a 4096-dimensional semantic vector of an item generated by LLM, containing key information such as the item's classification, features, and target audience.
[0041] 4. Hierarchical Comparative Learning Overall Design To address the misalignment between LLM semantic features and graph structure features, and to improve the robustness of the model in scenarios with sparse or perturbed data, this invention designs a hierarchical contrastive learning layer. Through two stages of contrastive training—"random edge dropout enhancement" and "noise injection enhancement"—the two types of features are gradually aligned accurately.
[0042] 4.1 First-level comparative learning design The core objective of the first layer of contrastive learning is to achieve initial alignment between semantic features and subdomain structural features, while simultaneously simulating data sparsity scenarios to improve the model's robustness against interference. Specifically, this layer incorporates three types of features into the contrastive training: first, subdomain structural features derived from domain-specific graph convolutions (i.e., domain-specific structural features). (Reflecting user-item interaction patterns in a specific subdomain), and secondly, semantic features derived from LLM. (Reflecting the semantic matching degree of user-item), and thirdly, the structural features after random edge dropout processing (by randomly deleting 10%-20% of the user-item interaction edges in the graph, simulating the situation where some interaction data is missing in real-world scenarios). As one possible implementation method, By representing user domain specificity Item domain specificity representation Perform vector concatenation operation ( ) to obtain, that is As one possible implementation method, By calculating the normalized user semantic vector With item semantic vector The cosine similarity is obtained, that is Contrastive training is achieved through a loss function: for each positive user-item pair (i.e., user-item pairs with interaction), the similarity between its "subdomain structural features and LLM semantic features" is calculated, and a log-softmax function is used to give this similarity the highest weight among all "subdomain structural features and random dropout features" similarities, thereby guiding the model to align semantic features and subdomain structural features into the same embedding space. Simultaneously, for negative pairs (i.e., user-item pairs without interaction), their similarity score is reduced to prevent the model from misclassifying mismatched feature pairs as aligned. The temperature coefficient t is set to 0.07, a value verified experimentally to effectively balance the similarity differences between positive and negative samples, avoiding poor alignment results caused by excessive concentration of similarity scores.
[0043] First-layer contrastive learning loss function: Where M represents the number of positive samples, i.e. the total number of user-item interaction pairs, which determines the scale of the loss function calculation; R represents the set of user-item interactions, with positive samples marked as "1" representing user interactions such as clicking, purchasing, or adding to favorites; , These represent user-item pairs respectively. The subdomain structural feature vectors and LLM semantic feature vectors are the core alignment objects for contrastive training; It is generated by dropping out random edges of structural features (negative sample features) and removing 10%-20% of the interactive edges to simulate data sparsity scenarios. This represents the temperature coefficient, which was set to 0.07 in the experiment to scale the similarity score and enhance the distinction between positive and negative samples. This represents the cosine similarity function, used to calculate the similarity between two types of feature vectors.
[0044] 4.2 Second-layer comparative learning design The second-layer contrastive learning (noise injection enhancement) further refines the feature alignment effect and improves the model's robustness by introducing noise injection, building upon the initial alignment in the first layer. The comparison object in this layer is adjusted to: subdomain structural features. The LLM semantic features optimized after the first layer of contrastive learning (already possessing preliminary alignment capabilities) and features after noise injection processing (Generated by adding Gaussian noise with a mean of 0 and a variance of 0.01 to the original features). The parameter selection of Gaussian noise has been verified through multiple experiments. It can add appropriate perturbation without destroying the core semantic and structural information of the features, while avoiding feature distortion caused by excessive noise. The calculation logic of the second-layer contrastive loss is the same as that of the first layer. The logarithmic softmax function is used to maximize the similarity score of positive sample pairs of "subdomain structural features - optimized LLM features" while reducing the similarity score of negative sample pairs of "subdomain structural features - noise-injected features". The core value of this stage is: on the one hand, to further reduce the difference in the embedding space of semantic features and structural features through secondary contrast, so as to achieve more accurate alignment; on the other hand, to allow the model to learn to resist small perturbations through noise injection, so as to avoid the decrease in recommendation accuracy caused by data noise (such as accidental clicks, incorrect labeling of interactive data) in real scenarios.
[0045] Second-layer contrastive learning loss function: in, It is the user-item pair optimized after the first layer of contrastive learning. The LLM semantic feature vectors have already achieved preliminary alignment with the structural features of the subdomains; This represents the feature vector after noise injection, generated by adding Gaussian noise with a mean of 0 and a variance of 0.01 to enhance model robustness; the remaining symbols (M, R, t, ...) represent the feature vector after noise injection. (etc.) is consistent with the first layer of contrastive learning, ensuring that the computational logic of the two layers of contrastive training is consistent.
[0046] 4.3 Total Comparison Loss To ensure the synergistic effect of the two-stage contrastive learning, this invention directly sums the contrastive losses of the two layers to form the total contrastive loss. The design logic of the total comparison loss is as follows: the first layer loss is responsible for initial alignment and sparsity resistance, while the second layer loss is responsible for precise alignment and perturbation resistance. The combination of the two can cover the entire process from initial feature matching to fine-grained optimization, avoiding the local optima problem that may exist in single-level comparison (e.g., performing only the first layer comparison may lead to insufficient alignment, and performing only the second layer comparison may be difficult to converge due to the lack of initial alignment foundation). By minimizing the total comparison loss, the model can stably align LLM semantic features and graph structure features to the same embedding space, laying a good feature foundation for the subsequent fusion stage.
[0047] 5. Two-stage adaptive fusion mechanism To achieve optimal integration of features from different sources (LLM semantic features, subdomain structural features, and globally shared structural features), this invention designs a two-stage adaptive fusion mechanism. By dynamically adjusting the weights, the contribution of various features is balanced, ensuring that the fused features can reflect domain specificity, utilize cross-domain shared knowledge, and retain the personalized advantages of LLM semantic features.
[0048] 5.1 LLM-Subfield Weighted Summation The core objective of the first phase of fusion is to balance the weights of LLM semantic features and subdomain structural features, dynamically adjusting their proportions based on user interaction behavior within the subdomain and the information value of the features. Specifically, the weight adjustment is based on two key indicators: the frequency of user interaction within the subdomain and the information gain of LLM features on subdomain features. Regarding interaction frequency, a higher proportion of user interactions within a subdomain relative to their total interactions indicates richer and more representative behavioral data for that subdomain, meaning the subdomain structural features can more accurately reflect user preferences within that subdomain. Therefore, the weight β of the subdomain features increases accordingly, reaching a maximum of 0.8. Regarding information gain, it is calculated by substituting the difference between "prediction accuracy using only subdomain features" and "prediction accuracy after adding LLM features." A larger difference indicates that LLM features can supplement the subdomain features with more valuable semantic information (such as potential user needs not reflected through interaction behavior). Therefore, the weight α of LLM features increases accordingly, reaching a maximum of 0.7. For cold-start users (i.e. new users with no interaction data), since the interaction frequency and information gain cannot be calculated, α and β are both set to 0.5 by default. This balances the contributions of the two types of features and avoids recommendation bias caused by the lack of a single feature.
[0049] Weight adjustment logic: The higher the subdomain interaction frequency, the larger β is, with a maximum of 0.8; (IG is the information gain function, and its calculation formula is:) The higher the LLM feature information gain, the larger α becomes, up to a maximum of 0.7; Cold start users: , .
[0050] in This represents the user-item pairs after the first phase of integration. The feature vector (i.e. the first fusion feature vector) contains collaborative information of LLM semantic features and subdomain structural features; Represents user-item pairs The subdomain structural feature vectors, derived from domain-specific graph convolution operations, reflect the interaction patterns of the subdomain.
[0051] 5.2 Subdomain-Global Weighted Summation The core objective of the second-stage fusion is to balance the weights of sub-domain features and globally shared structural features obtained from the first-stage fusion. The proportions of these two features are dynamically adjusted based on the recommendation task type (cross-domain migration or precise intra-domain recommendation) to achieve "task-adaptive" feature fusion. For cross-domain migration tasks (i.e., recommending items from new domains that users have not interacted with), since user interaction data from the target domain is usually sparse, more globally shared features (such as cross-domain common preferences) are needed to compensate for the lack of target domain data. Therefore, the weight γ of the sub-domain features is set to 0.6, and the weight of the globally shared features is... Setting γ to 0.4 ensures effective cross-domain knowledge transfer by increasing the contribution of global features. For intra-domain accurate recommendation tasks (i.e., recommending new items in domains that users have already interacted with), user behavior data in that domain is relatively rich, and subdomain features can more accurately reflect users' domain-specific preferences. Therefore, γ is set to 0.8, and the weight of the global shared features is set to 0.2 to improve the accuracy of recommendations by highlighting the contribution of subdomain features.
[0052] Weight adjustment logic: Cross-domain migration task: (Subdomain features account for 60%, global features account for 40%), supplementing insufficient target domain data with global features; precise recommendation task within the domain: (Subdomain features account for 80%, global features account for 20%), improving recommendation accuracy through subdomain features.
[0053] in, This represents the user-item pairs after the second phase of integration. The feature vector (i.e., the second fusion feature vector) contains collaborative information of subdomain specificity and globally shared knowledge; Represents user-item pairs The globally shared structural feature vectors, derived from convolutional operations on the domain-shared graph, reflect cross-domain common preferences and serve as a viable implementation method. Specifically, by using user-item pairs In the convolution output of the domain-shared graph and Vector concatenation is performed to generate the vector; γ represents the weight coefficient of the subdomain features, with a value range of [0.6, 0.8], which is dynamically adjusted according to the task type.
[0054] 5.3 Post-processing of fusion To further optimize the expressive power of the fused vectors and ensure their suitability for subsequent recommendation and ranking tasks, this invention performs L2 normalization and ReLU activation post-processing on the fused vectors from the second stage. The core function of L2 normalization is to unify the amplitude of the fused vectors to a scale with an L2 norm of 1, avoiding the impact of differences in vector amplitudes between different user-item pairs on the fairness of the ranking results. For example, if the amplitude of a fused vector is significantly larger than other vectors, it may still occupy a higher position in the ranking even if its actual matching degree is not high. The ReLU activation function filters out meaningless negative features (such as the "potential aversion attribute" of users to items) by setting the negative feature values in the vectors to 0, while introducing nonlinear transformations to enhance the model's ability to express complex feature relationships, ensuring that the fused vectors can more accurately reflect the matching value of users and items.
[0055] in, This represents the user-item pairs ultimately used for recommendation ranking. The feature vector (i.e. the final recommendation feature vector) is the core recommendation basis for the model output; Represents the ReLU activation function, calculated using the following formula: This is used to filter negative eigenvalues and introduce nonlinearity; yes The L2 norm is used for normalization operations to ensure that the magnitude of the fused vector is uniform.
[0056] 6. Learning and Training Process To ensure stable convergence of the model framework and good generalization ability, this invention designs a complete learning and training process that includes a total loss function, optimization strategy, regularization and training assistance strategy, so as to achieve a balance between the model in three dimensions: "accurate feature alignment", "high prediction accuracy" and "strong generalization ability".
[0057] 6.1 Total Loss Function The model's total loss function consists of two parts: contrastive loss. With fusion loss The two work together to ensure that the model achieves both feature alignment and recommendation prediction accuracy. The core function of the contrastive loss is to guide the alignment of LLM semantic features and graph structure features towards the same embedding space, resolving the semantic-structural misalignment problem; the core function of the fusion loss is to evaluate the final fused vector for user-item interaction labels. The prediction accuracy is improved to ensure that the feature vectors output by the model can effectively distinguish between positive and negative interaction samples. The fusion loss adopts the L2 loss function, which measures the difference between the predicted value and the true value by calculating the sum of the squared differences between the final vector and the interaction label. The smaller the squared difference, the more accurate the prediction of the interaction behavior by the final vector. The total loss function achieves the dual optimization goals of "alignment" and "prediction" by directly summing the contrastive loss and the fusion loss: if only the contrastive loss is optimized, the model may have the problem of "feature alignment but inaccurate prediction"; if only the fusion loss is optimized, the model may have insufficient generalization ability due to feature misalignment. The combination of the two can ensure that the model improves the feature alignment quality and prediction accuracy simultaneously during training.
[0058] Fusion loss (L2 loss, which measures the difference between the prediction and the true label): Total loss function: in, The user-item interaction label represents the interaction between user u and item i, where 1 indicates an interaction between user u and item i (positive sample), and 0 indicates no interaction (negative sample); the final feature vector is derived from the interaction label. The smaller the L2 loss value, the higher the prediction accuracy; This represents the total contrastive loss, derived from the hierarchical contrastive learning layers, which ensures feature alignment. The total loss function of the model is the core objective for optimizing model parameters.
[0059] 6.2 Optimize and update formulas To efficiently optimize the total loss function, this invention employs the Adam optimizer, which combines the advantages of momentum gradient descent and adaptive learning rate. This optimizer effectively handles the complex parameter space of the HDAF-LLM framework (including graph convolution weights, LLM embedding parameters, fusion weights, and other parameters), achieving stable and fast convergence. During parameter updates, the outputs of each layer of the model (including features from domain-decoupled convolutions, LLM-generated vectors, contrastive loss, and fusion loss) are first calculated via forward propagation. Then, the total loss is calculated via backpropagation. The gradients of all model parameters θ are calculated, and the parameters are updated based on the gradient direction and the learning rate η. The optimal learning rate is determined through multiple cross-validations in the experiments. This learning rate avoids slow convergence caused by an excessively small learning rate (e.g., ...). The learning rate may need thousands of epochs to converge, while avoiding parameter oscillations caused by an excessively large learning rate (e.g., An inefficient learning rate might cause the loss function to fluctuate around its optimum and fail to converge. A batch size of 64 is also set, which balances memory usage and training efficiency on the NVIDIA A100 GPU. Too small a batch size leads to large gradient estimation variance, while too large a batch size consumes excessive GPU memory and increases the time per iteration.
[0060] Parameter update rules: Where θ represents the set of model parameters, including the domain-specific transformation matrix. Domain-shared transformation matrix LLM embedding parameters, fusion weights α / β / γ, etc.; , Let represent the model parameters in the t-th and t+1-th iterations, respectively. Parameter updates are achieved through gradient descent. η represents the learning rate, with the optimal value in the experiment being... The total loss was determined through cross-validation. In parameters The gradient at a given point reflects the direction and extent of the influence of parameter changes on the loss function.
[0061] 6.3 Regularization Terms This invention adds an L2 regularization term to the weight parameters of graph convolutional layers, achieving regularization by limiting the magnitude of the weight parameters. Graph convolutional layers are the core module for capturing structural features in a model, and their weight parameters are large in scale (including domain-specific transformation matrices and globally shared transformation matrices). Without constraints, problems such as excessively large parameters and overfitting to noise in the training data can easily occur. The L2 regularization term is calculated by summing the L2 norms of all graph convolutional layer weight matrices and multiplying them by the regularization strength λ, forming the regularization loss. By incorporating this regularization loss into the total loss function, the model will simultaneously minimize both the "prediction loss" and the "weight size" during optimization, thus achieving a balance between fitting the data and controlling the complexity of the parameters. In the experiment, the regularization strength λ is set to... This value is determined through cross-validation. If λ is too large, it will lead to excessive compression of weights and underfitting of the model; if λ is too small, it will not effectively limit the size of the weights, and the model may still overfit.
[0062] Regularization loss: The final form of the total loss (including regularization): in, This represents the weight matrix of the graph convolution at layer l, which includes the domain-specific transformation matrix. Domain-shared transformation matrix λ represents the regularization strength, which is set to λ in the experiment. Balancing the model's fitting ability with its generalization ability; This represents the sum of the L2 norms of the weight matrices of all graph convolutional layers, used to measure the size of the weight parameters; This represents the regularization loss, which, when added to the total loss, is used to limit the size of the weight parameters and prevent overfitting.
[0063] 6.4 Training Assistance Strategies To further improve the training stability and result reliability of the model, this invention designs three key training assistance strategies: early stopping strategy, temporal data partitioning, and multiple rounds of independent experiments. The core logic of the early stopping strategy is to monitor the NDCG@10 metric (a core indicator reflecting the quality of recommendation ranking) of the validation set in real time during training. If this metric does not improve for three consecutive epochs, training is stopped. This effectively avoids overfitting on the validation set (e.g., the training set loss continues to decrease in the later stages of training, but the validation set loss begins to increase), while reducing unnecessary training time. The data partitioning adopts a temporal strategy: all user-item interaction data are divided into a training set (80%), a validation set (10%), and a test set (10%) in chronological order. That is, earlier interaction data is used for training, and later data is used for validation and testing. This partitioning method can simulate the temporal nature of real recommendation scenarios. The model learns from historical interaction data and predicts future interaction behaviors, ensuring the model's practical application value. If random partitioning is used, the training set may contain future data, leading to a "data leakage" problem and overestimating model performance. The reliability of the results is ensured through multiple rounds of independent experiments: all experiments were run on an NVIDIA A100 GPU using the PyTorch framework, and each experiment was run independently three times (using random seeds 42, 43, and 44 respectively), with the final result being the average of the three experiments. This strategy effectively eliminates the influence of random factors (such as minor differences in parameter initialization and data partitioning) on the experimental results, ensuring that the reported performance metrics are statistically significant and avoiding result bias caused by random fluctuations in a single experiment.
[0064] To verify the effectiveness of the present invention, the following experiment was conducted: 1 Experimental Setup Datasets: Six Amazon subdomain datasets are used, covering multiple categories such as Sports, Electronics, Phone, All Beauty, Luxury Beauty, and Clothing Shoes. They are divided into training, validation, and test sets in an 8:1:1 ratio.
[0065] Baseline comparison: More than 10 mainstream methods, including single-domain recommendation (GRU4Rec, SASR), cross-domain recommendation (GA-DTCDR, TriCDR), and LLM-based recommendation (SAID, LLM-ESR).
[0066] Large Language Model: Adaptable to mainstream LLMs such as ChatGLM and Llama, with user / item vector generation logic adjusted through prompt engineering.
[0067] Hyperparameters: The optimal learning rate is 10⁻³, the batch size is 64, and the L2 regularization strength can be adjusted according to the specific dataset.
[0068] 2. Experimental Results On six Amazon subdomain datasets (Sport, Electronics, Phone, etc.), the HR@10 (hit rate) and NDCG@10 (normalized depreciation cumulative gain) metrics significantly outperform existing baseline methods, with relative improvements of 0.85%-1.95%. Experimental metrics are as follows: Figure 3 As shown, the recommended performance of the present invention is superior.
[0069] Specifically, this invention exhibits strong anti-interference capabilities: by reducing cross-domain preference interference through decoupled modeling, it maintains stable performance even in scenarios with significant domain differences (such as Luxury Beauty and Electronics). It also demonstrates outstanding generalization ability: mitigating data sparsity and cold start problems through cross-domain knowledge transfer and semantic-structural alignment, it enhances the model's robustness in complex multi-domain scenarios. Furthermore, it offers flexible adaptability: the two-stage adaptive fusion mechanism dynamically adapts to different user interaction frequencies and domain characteristics, making it suitable for diverse recommendation scenarios.
[0070] Ablation experiments verified that global heterogeneous graphs, domain-specific graph convolutions, LLM features, and hierarchical contrastive learning are the core components for improving performance, and their removal leads to a significant performance degradation.
[0071] This invention can be directly applied to scenarios such as cross-category recommendation on e-commerce platforms, cross-content recommendation on streaming media platforms, and course recommendation on knowledge payment platforms. It can also be extended to the field of personalized services that require cross-scenario preference migration.
[0072] Based on the above embodiments, such as Figure 4 As shown, this invention also proposes a cross-domain recommendation system that integrates a large language model and hierarchical contrastive learning, comprising: The domain decoupling feature extraction module is used to construct a domain-specific graph structure and a globally shared graph structure for user-item interaction data, respectively; extract domain-specific structural features from the domain-specific graph structure through domain-specific graph convolution operation; and extract globally shared structural features from the domain-shared graph structure through domain-shared graph convolution operation. The semantic feature generation and dynamic weighting module is used to generate user semantic vectors and item semantic vectors as semantic features based on a large language model; and dynamically calculates and adjusts the weights of long-term preference components and short-term preference components in the user semantic vectors according to the user's long-term and short-term interaction frequencies. The hierarchical contrastive learning alignment module is used to perform two-stage contrastive learning, including random edge dropping and noise injection, based on the domain-specific structural features extracted in the aforementioned steps and the generated semantic features, to obtain aligned semantic and structural features. A two-stage adaptive feature fusion module is used for: in the first stage, dynamically fusing the aligned semantic features and the domain-specific structural features based on the user's interaction frequency in the target subdomain and the information gain of the semantic features to obtain a first fused feature; in the second stage, dynamically fusing the first fused feature and the globally shared structural features based on whether the recommendation task type is cross-domain migration or intra-domain recommendation to generate a second fused feature, thereby obtaining the final recommendation feature vector. The model training and recommendation prediction module is used to predict user-item interactions based on the final recommendation feature vector, and to construct a total loss function that includes both contrastive learning loss and prediction loss to optimize all model parameters.
[0073] This invention separates and models global heterogeneous graphs and domain-specific heterogeneous graphs, capturing cross-domain shared knowledge and domain-specific features respectively, effectively reducing cross-domain bias interference. By fusing LLM to generate fine-grained semantic vectors and combining hierarchical contrastive learning (including edge dropout and noise injection data augmentation), it achieves precise alignment between semantic features and graph structure features. Furthermore, through two-stage adaptive fusion, it dynamically balances the contribution weights of LLM semantic features, domain-specific structural features, and globally shared structural features, adapting to different domain characteristics and user interaction scenarios, thus improving the effectiveness of fusion.
[0074] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A cross-domain recommendation method fusing a large language model and hierarchical contrastive learning, characterized in that, The method comprises the following steps: Step 1: constructing a field-specific graph structure and a global shared graph structure for user-item interaction data respectively; extracting field-specific structural features from the field-specific graph structure through field-specific graph convolution operation; extracting global shared structural features from the field-shared graph structure through field-shared graph convolution operation; Step 2: generating user semantic vectors and item semantic vectors as semantic features based on a large language model; dynamically calculating and adjusting the weights of long-term preference components and short-term preference components in the user semantic vectors according to the long-term and short-term interaction frequencies of the user; Step 3: based on the field-specific structural features extracted in the foregoing steps and the generated semantic features, performing two-stage contrastive learning containing random edge dropout and noise injection to obtain aligned semantic features and structural features; Step 4: in the first stage, dynamically fusing the aligned semantic features and the field-specific structural features according to the interaction frequency of the user in the target subfield and the information gain of the semantic features to obtain first fusion features; in the second stage, dynamically fusing the first fusion features and the global shared structural features according to the recommendation task type being cross-domain migration or intra-domain recommendation to generate second fusion features, and then obtaining a final recommendation feature vector; Step 5: predicting user-item interaction based on the final recommendation feature vector, and constructing a total loss function containing contrastive learning loss and prediction loss to optimize all parameters of the model.
2. The cross-domain recommendation method of fusing large language models and hierarchical contrastive learning according to claim 1, characterized in that, The field-specific graph convolution operation in step 1 is used to update the user representation, and the formula is: in This indicates that user u is in the domain d. The updated hidden state of the layer contains the unique interactive features specific to that domain. Indicates the activation function; The domain d represents the first... The domain-specific transformation matrix of the layer; Let represent the set of neighboring nodes of user u in domain d, where the neighboring nodes are the items that the user has interacted with in domain d; λ is the regularization term; Indicates that the neighboring node v is at the th The original hidden state of the layer.
3. The method of claim 2, wherein the method further comprises: The global shared graph convolution operation in step 1 is used to update the user representation, and the formula is: wherein represents the user u's layer's domain-shared hidden state, containing common features that are transferable across domains; represents the user u's layer's domain-shared transformation matrix; represents the user u's neighborhood node set in all domains.
4. The method of claim 1, wherein the method further comprises: The logic of dynamically adjusting the weight of the user semantic vector in step 2 comprises: dynamically calculating the long-term preference weight α(t) and the short-term preference weight β(t) based on the long-term interaction frequency and the short-term interaction frequency of the user; the user semantic vector generated by the following equation: wherein , , respectively denote the long-term preference vector, the short-term preference vector and the core need vector of the user u.
5. The method of claim 1, wherein the method further comprises: The loss function of the first-stage contrastive learning in step 3 is: where M represents the number of positive samples, i.e., the total number of user-item interactions; R represents the set of user-item interactions; represents the domain-specific structural feature vector of the user-item pair represents the semantic feature vector of the user-item pair represents the domain-specific structural feature vector of the user-item pair represents the semantic feature vector of the user-item pair is the feature vector obtained after random edge dropping on the structural feature; represents the temperature coefficient; represents the cosine similarity function.
6. The method of claim 5, wherein the method further comprises: The loss function of the second-stage contrastive learning in step 3 is: wherein, represents the semantic feature vector of the user-item pair after the first stage of contrastive learning, represents the feature vector after noise injection. 7. The method of claim 1, wherein the method further comprises: The specific way of the first-stage fusion in step 4 is: wherein, represents the feature vector of the user-item pair after the first stage fusion; is the normalized user semantic feature vector; represents the domain-specific structural feature vector of the user-item pair and are weight coefficients, the specific value of is adjusted according to the information gain change of the semantic feature, the specific value of is adjusted according to the interaction frequency change of the target subfield. 8. The method of claim 7, wherein the method further comprises: The specific way of the second-stage fusion in step 4 is: in, This represents the user-item pairs after the second phase of integration. eigenvectors; Represents user-item pairs The globally shared structural feature vector; γ represents the weight coefficient, and the specific value of γ is adjusted according to whether the recommendation task is cross-domain migration or intra-domain recommendation.
9. The method of claim 8, wherein the method further comprises: The step 4 further comprises post-processing the post-processing: wherein represents a user-item pair finally used for recommendation ranking ; represents a ReLU activation function; is L2 norm of 10. A cross-domain recommendation system fusing large language models and hierarchical contrastive learning, characterized in that, The method comprises the following steps: a field decoupling feature extraction module for constructing a field-specific graph structure and a global shared graph structure for user-item interaction data respectively; extracting field-specific structural features from the field-specific graph structure through field-specific graph convolution operation; extracting global shared structural features from the field-shared graph structure through field-shared graph convolution operation; a semantic feature generation and dynamic weighting module for generating user semantic vectors and item semantic vectors as semantic features based on a large language model; dynamically calculating and adjusting the weights of long-term preference components and short-term preference components in the user semantic vectors according to the long-term and short-term interaction frequencies of the user; a hierarchical contrastive learning alignment module for performing two-stage contrastive learning containing random edge dropout and noise injection based on the field-specific structural features extracted in the foregoing steps and the generated semantic features to obtain aligned semantic features and structural features; A two-stage adaptive feature fusion module is used for: in the first stage, dynamically fusing the aligned semantic features and the domain-specific structural features based on the user's interaction frequency in the target subdomain and the information gain of the semantic features to obtain the first fused feature; In the second stage, depending on whether the recommendation task type is cross-domain migration or intra-domain recommendation, the first fusion feature and the globally shared structural feature are dynamically fused to generate the second fusion feature, and then the final recommendation feature vector is obtained. The model training and recommendation prediction module is used to predict user-item interactions based on the final recommendation feature vector, and to construct a total loss function that includes both contrastive learning loss and prediction loss to optimize all model parameters.