Test-Time Adaptation on Recommender System with Data-Centric Graph Transformation
Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence. Main Track. Pages 4579-4587.
https://doi.org/10.24963/ijcai.2025/510
Keywords
- Knowledge Representation and Reasoning: KRR: Learning and reasoning
- Machine Learning: ML: Deep learning architectures
- Data Mining: DM: Mining graphs
Abstract
Distribution shifts in recommender systems between training and testing in user-item interactions lead to inaccurate recommendations. Despite the promising performance of test-time adaptation technology in various domains, it still faces challenges in recommender systems due to the impracticality of fine-tuning models and the infeasibility of obtaining test-time labels. To address these challenges, we first propose a Test-Time Adaptation framework for Graph-based Recommender system, named TTA-GREC, to dynamically adapt user-item graphs at test time in a data-centric way, handling distribution shifts effectively. Specifically, our TTA-GREC targets KG-enhanced GNN-based recommender systems with three core components: (1) Pseudo-label guided UI graph transformation for adaptive improvement; (2) Rationale score guided KG graph revision for semantic enhancement; and (3) Sampling-based self-supervised adaptation for contrastive learning. Experiments demonstrate TTA-GREC's superiority at test time and provide new data-centric insights on test-time adaptation for better recommender system inference.
- [Adomavicius et al., 2021] Gediminas Adomavicius, Kon- stantin Bauman, Alexander Tuzhilin, and Moshe Unger. Context-aware recommender systems: From foundations to recent developments. In Recommender systems hand- book, pages 211-250. Springer, 2021.
- [Ashraf et al., 2022] Hassan Ashraf, Asim Waris, Muham- mad Fazeel Ghafoor, Syed Omer Gilani, and Imran Khan Niazi. Melanoma segmentation using deep learning with test-time augmentations and conditional random fields. Scientific Reports, 12(1):3948, 2022.
- [Azimi et al., 2022] Fatemeh Azimi, Sebastian Palacio, Fed- erico Raue, Jörn Hees, Luca Bertinetto, and Andreas Den- gel. Self-supervised test-time adaptation on video data. In Proceedings of the IEEE/CVF Winter Conference on Ap- plications of Computer Vision, pages 3439-3448, 2022.
- [Bu et al., 2024] Weixin Bu, Xiaofeng Cao, Yizhen Zheng, and Shirui Pan. Improving augmentation consistency for graph contrastive learning. Pattern Recognition, 148:110182, 2024.
- [Chen et al., 2020] Ting Chen, Simon Kornblith, Moham- mad Norouzi, and Geoffrey Hinton. A simple framework for contrastive learning of visual representations. In In- ternational conference on machine learning, pages 1597- 1607. PMLR, 2020.
- [Choudhary et al., 2021] Shivani Choudhary, Tarun Luthra, Ashima Mittal, and Rajat Singh. A survey of knowledge graph embedding and their applications. arXiv preprint arXiv:2107.07842, 2021.
- [Guo et al., 2020] Qingyu Guo, Fuzhen Zhuang, Chuan Qin, Hengshu Zhu, Xing Xie, Hui Xiong, and Qing He. A survey on knowledge graph-based recommender systems. IEEE Transactions on Knowledge and Data Engineering, 34(8):3549-3568, 2020.
- [He et al., 2021] Yufan He, Aaron Carass, Lianrui Zuo, Blake E Dewey, and Jerry L Prince. Autoencoder based self-supervised test-time adaptation for medical image analysis. Medical image analysis, 72:102136, 2021.
- [He et al., 2024] Ming He, Han Zhang, Zihao Zhang, and Chang Liu. Invariant representation learning to popularity distribution shift for recommendation. World Wide Web, 27(2):10, 2024.
- [Hou et al., 2023] Yan-e Hou, Wenbo Gu, WeiChuan Dong, and Lanxue Dang. A deep reinforcement learning real- time recommendation model based on long and short-term preference. International Journal of Computational Intel- ligence Systems, 16(1):4, 2023.
- [Hu et al., 2020] Ziniu Hu, Yuxiao Dong, Kuansan Wang, and Yizhou Sun. Heterogeneous graph transformer. In Proceedings of the web conference 2020, pages 2704- 2710, 2020.
- [Huang et al., 2025] Yujin Huang, Zhi Zhang, Qingchuan Zhao, Xingliang Yuan, and Chunyang Chen. Themis: To- wards practical intellectual property protection for post- deployment on-device deep learning models. In Proceed- ings of the 34th USENIX Security Symposium (USENIX Security 25), 2025.
- [Jha et al., 2021] Debesh Jha, Pia H Smedsrud, Dag Jo- hansen, Thomas De Lange, Håvard D Johansen, Pål Halvorsen, and Michael A Riegler. A comprehensive study on colorectal polyp segmentation with resunet++, condi- tional random field and test-time augmentation. IEEE journal of biomedical and health informatics, 25(6):2029- 2040, 2021.
- [Lee et al., 2018] Youngnam Lee, Sang-Wook Kim, Sunju Park, and Xing Xie. How to impute missing ratings? claims, solution, and its application to collaborative filter- ing. In Proceedings of the 2018 World Wide Web Confer- ence, pages 783-792, 2018.
- [Meng et al., 2022] Xiangwu Meng, Yulu Du, Yujie Zhang, and Xiaofeng Han. A survey of context-aware rec- ommender systems: from an evaluation perspective. IEEE Transactions on Knowledge and Data Engineering, 35(7):6575-6594, 2022.
- [Mishra et al., 2020] Pushkar Mishra, Aleksandra Piktus, Gerard Goossen, and Fabrizio Silvestri. Node masking: Making graph neural networks generalize and scale better. arXiv preprint arXiv:2001.07524, 2020.
- [Rong et al., 2019] Yu Rong, Wenbing Huang, Tingyang Xu, and Junzhou Huang. Dropedge: Towards deep graph con- volutional networks on node classification. arXiv preprint arXiv:1907.10903, 2019.
- [Roy et al., 2023] Subhadeep Roy, Shankhanil Mitra, Soma Biswas, and Rajiv Soundararajan. Test time adaptation for blind image quality assessment. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 16742-16751, 2023.
- [Shafiloo et al., 2024] Reza Shafiloo, Marjan Kaedi, and Ali Pourmiri. Considering user dynamic preferences for mit- igating negative effects of long-tail in recommender sys- tems. Information Sciences, 669:120558, 2024.
- [Shanmugam et al., 2021] Divya Shanmugam, Davis Blalock, Guha Balakrishnan, and John Guttag. Better aggregation in test-time augmentation. In Proceedings of the IEEE/CVF international conference on computer vision, pages 1214-1223, 2021.
- [Shen et al., 2023] Chenglei Shen, Xiao Zhang, Wei Wei, and Jun Xu. Hyperbandit: Contextual bandit with hy- pernewtork for time-varying user preferences in stream- ing recommendation. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management, pages 2239-2248, 2023.
- [Tian et al., 2021] Yu Tian, Yuhao Yang, Xudong Ren, Pengfei Wang, Fangzhao Wu, Qian Wang, and Chenliang Li. Joint knowledge pruning and recurrent graph convolu- tion for news recommendation. In Proceedings of the 44th international ACM SIGIR conference on research and de- velopment in information retrieval, pages 51-60, 2021.
- [Wang et al., 2019] Xiang Wang, Xiangnan He, Yixin Cao, Meng Liu, and Tat-Seng Chua. Kgat: Knowledge graph attention network for recommendation. In Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining, pages 950-958, 2019.
- [Wang et al., 2020] Dequan Wang, Evan Shelhamer, Shaoteng Liu, Bruno Olshausen, and Trevor Darrell. Tent: Fully test-time adaptation by entropy minimization. arXiv preprint arXiv:2006.10726, 2020.
- [Wang et al., 2021] Xiang Wang, Tinglin Huang, Dingxian Wang, Yancheng Yuan, Zhenguang Liu, Xiangnan He, and Tat-Seng Chua. Learning intents behind interactions with knowledge graph for recommendation. In Proceedings of the web conference 2021, pages 878-887, 2021.
- [Wu et al., 2024] Man Wu, Xin Zheng, Qin Zhang, Xiao Shen, Xiong Luo, Xingquan Zhu, and Shirui Pan. Graph learning under distribution shifts: A comprehensive sur- vey on domain adaptation, out-of-distribution, and contin- ual learning. arXiv preprint arXiv:2402.16374, 2024.
- [Xi et al., 2024] Yunjia Xi, Weiwen Liu, Jianghao Lin, Muyan Weng, Xiaoling Cai, Hong Zhu, Jieming Zhu, Bo Chen, Ruiming Tang, Yong Yu, et al. Efficient and deployable knowledge infusion for open-world recom- mendations via large language models. arXiv preprint arXiv:2408.10520, 2024.
- [Yang et al., 2023] Yuhao Yang, Chao Huang, Lianghao Xia, and Chunzhen Huang. Knowledge graph self-supervised rationalization for recommendation. In Proceedings of the 29th ACM SIGKDD conference on knowledge discovery and data mining, pages 3046-3056, 2023.
- [Zhang et al., 2023] An Zhang, Jingnan Zheng, Xiang Wang, Yancheng Yuan, and Tat-Seng Chua. Invariant collabora- tive filtering to popularity distribution shift. In Proceed- ings of the ACM Web Conference 2023, pages 1240-1251, 2023.
- [Zhao et al., 2019] Wayne Xin Zhao, Gaole He, Kunlin Yang, Hongjian Dou, Jin Huang, Siqi Ouyang, and Ji- Rong Wen. Kb4rec: A data set for linking knowledge bases with recommender systems. Data Intelligence, 1(2):121-136, 2019.
- [Zheng et al., 2023] Xin Zheng, Yixin Liu, Zhifeng Bao, Meng Fang, Xia Hu, Alan Wee-Chung Liew, and Shirui Pan. Towards data-centric graph machine learning: Re- view and outlook. arXiv preprint arXiv:2309.10979, 2023.
- [Zheng et al., 2024] Xin Zheng, Dongjin Song, Qingsong Wen, Bo Du, and Shirui Pan. Online gnn evaluation under test-time graph distribution shifts. In The Twelfth Interna- tional Conference on Learning Representations, 2024.
References were extracted automatically from the PDF and may contain errors.
Full text extracted automatically from the PDF; figures, tables and equations may differ. The PDF is the version of record.
1 Introduction
Recommender systems powered by knowledge graphs (KGs) and modeled by graph neural networks (GNNs) represent a branch of graph-based recommender systems, i.e., KGNNs. These systems [Guo et al., 2020; Choudhary et al., 2021; Yang et al., 2023] play crucial roles in capturing complex relationships and semantic information between users and items, enabling highly accurate, personalized, and contextaware recommendations. Typically, KGNNs learn from both user-item (UI) interaction graphs and knowledge graphs (KGs), which enrich user-item relationships through KGs and capture high-order contextual information through graph convolutions, leading to high-quality user-item representations.
However, a major challenge for KGNN-based recommender systems is distribution shift between training and test data [Wu et al., 2024]. It shows in user-item relationship changes, item popularity fluctuations, and contextual factors. First, the dynamic nature of user preferences leads to discrepancies between user behaviors during training and test phases [Shen et al., 2023; Shafiloo et al., 2024]. Second, fluctuations in item popularity may cause users to interact with cold or newly introduced items during testing, which are poorly represented in the training data, thereby reducing recommendation accuracy [Zhang et al., 2023; He et al., 2024]. Finally, contextual variations, such as seasonality and marketing campaigns [Adomavicius et al., 2021; Meng et al., 2022], further exacerbate the differences between interactions in the training and test stages. These distribution shifts result in a significant decrease in model performance during testing.
∗ Corresponding author.

Inspired by test-time adaptation (TTA) methods in computer vision [He et al., 2021; Azimi et al., 2022; Roy et al., 2023], TTA has emerged as a promising strategy for dynamically adjusting data or fine-tuning model parameters at test time to address distribution shifts, improving generalization. However, existing TTA methods fail in recommender systems due to key challenges: C1: Impracticality of fine-tuning models: Model updates during testing are resource-intensive and introduce delays, so it is unsuitable for real-time recommendations [Hou et al., 2023; Xi et al., 2024]. C2: Infeasibility of obtaining test-time labels: Sparse data and absent supervision hinder semantic learning and adaptation [Lee et al., 2018].
To address these challenges, we first propose a novel TestTime Adaptation framework for Graph-based Recommender system, named TTA-GREC, to dynamically adapt user-item graphs at test time in a data-centric manner, enhancing the capability of recommender system to handle the distribution shift issue. As shown in Figure 1, our proposed TTAGREC dynamically adapts the test-time graphs in a datacentric manner, without fine-tuning models.
Specifically, our proposed TTA-GREC consists of three key modules: (a) Pseudo-label guided UI graph transformation for adaptive improvement: It refines the user-item graph by generating pseudo-labels, pruning edges, and adaptively sampling key interactions to enhance semantic information; (b) Rational score guided KG graph revision for semantic enhancement: Rational score is computed by combining entity and relation embeddings. It induces a series of self-supervised tasks to achieve semantic enhancement and thus robust adaptation. (c) Sampling-based self-supervised adaptation for contrastive learning: It enhances semantic representations through a set of self-supervised tasks, enabling robust adaptation through contrastive learning. Extensive experiments on multiple public datasets demonstrate that TTA-GREC significantly outperforms existing methods on key metrics such as Recall and NDCG (e.g., 4.46% Recall and 1.86× NDCG improvement in Last-FM).
In summary, the contributions of our proposed method are listed as follows:
- First TTA Framework on Recommendation. To the best of our knowledge, we are the first to propose a Test-Time Adaptation framework for Graph-based Recommender system, i.e., TTA-GREC, to dynamically adapt user-item graphs at test time in a data-centric manner for better model generalization and adaptability.
- Dual UI and KG Graph Data-centric Transformation. Our proposed TTA-GREC contains (a) Pseudolabel guided UI transformation, (b) Rational score guided KG graph revision, and (c) Sampling-based selfsupervised adaptation.
- Superior Test-Time Performance. Extensive experiments conducted on multiple public datasets demonstrate that our TTA-GREC significantly enhances the test-time inference ability of KGNN-based recommendation systems.
2 RelatedWork
Test-Time Adaptation. Test-time adaptation (TTA) seeks to perform real-time refinements of test data or adjust the model parameters during the model deployment phase [Jha et al., 2021; Ashraf et al., 2022; Zheng et al., 2024; Huang et al., 2025]. This is done to enhance the model's generalization ability in conditions where there might be distribution shifts between the training and testing datasets. The existing TTA methods can mainly be divided into two categories: (1) Data-centric adaptation: These strategies expand or perturb the data, helping the model generalize well to the unseen data [Zheng et al., 2023]. For instance, DropEdge counters overfitting by uniformly dropping some edges [Rong et al., 2019]. Interaction masking or feature perturbation methods help in fusing the graphs [Mishra et al., 2020; Shanmugam et al., 2021]. (2) Model-centric adaptation: This approach involves modifying the model parameters during testing. This can be done by fine-tuning with self-supervised learning [Wang et al., 2020], or employing contrastive learning [Chen et al., 2020; Bu et al., 2024]. Such approaches remain inadequate for complex recommenders, such as KGNNbased systems that handle both UI and KG elements.
3 Test-Time Adaptation on Graph-based Recommendation System (TTA-GREC)
Preliminary. For a user-item (UI) interaction graph, we have Gui = {(u, v, yuv)}, where u ∈ U represents a user in the user set U and v ∈ E represents an item belonging to the entity set E. yuv = 1 indicates that user u interacted with item v, while yuv = 0 indicates no interaction. For a knowledge graph (KG), we have Gkg = {(h, r, t)}, which is represented as a triple set with a head entity h ∈ E, a tail entity t ∈ E, and a relation r ∈ R, where E and R denote the entity set and relation set in the knowledge graph, respectively.
Problem Definition. The objective of our TTA-GREC is to optimize the test UI graph G te ui dynamically at test time by constructing a test-time adaptation function F(u, v|Φ, Gui, Gkg,KGNNθ∗). Here F(·) is a function with learnable parameters Φ for test-time UI graph transformation. Additionally, KGNNθ∗ refers to the well-trained KGNN model optimized on the training set with parameters θ∗ , where its learning objective is to predict the interaction likelihood between a user u and an unseen item v. In our test-time adaptation process, KGNNθ∗ remains frozen without any parameter fine-tuning, emphasizing our data-centric approach.
KGNN Training. In the training phase of KGNN-based recommender models, the primary objective is to effectively capture the relationships among users, items, and KG entities, allowing the learning of expressive representations of user preferences and item attributes. Given a KG Gkg and a training UI graph G tr ui , the optimization objective can be written as:
where Lrec(·) is the recommendation loss (e.g., binary crossentropy loss or matrix factorization loss), and KGNNθ captures user and item features through the following function:
where {eu, eh, er} ∈ Rd represent embeddings of user u, entity h from KG, and relation r from UI and KG, respectively, and e′u , e′h ∈ Rd1 denote the updated user and entity embeddings from KGNN by propagating and aggregating neighbor information through GNN. Then, these embeddings are used to predict the interaction probability between user u and item v, providing interaction prediction results for the recommendation system. After training, the KGNNmodel learns the optimal parameters θ∗ , resulting in a well-trained recommender model KGNNθ∗ .
Test-Time KGNN Inference. For a real-world test useritem list with no existing connections, we still use graphbased representations for consistent expression, defined as G te ui = (ute , vte ). We assume that there may be a distribution shift between the training set G tr ui and the test set G te ui .

This shift primarily manifests as differences in the joint distribution of users and items, i.e., Ptr(u, v) ̸= Pte(u, v). Typically, the trained model KGNNθ∗ is used directly to infer the test graph, such as eu, ev = KGNNθ∗(G te ui , Gkg). However, due to potential distribution shifts at test time, the optimal parameters θ∗ learned from the training graph may not always be suitable for inference on the test graph. This could negatively impact the accuracy of predicting item interactions in the test graph, thereby harming the generalizability of the KGNN model.
3.1 Methodology
In this work, we propose a data-centric solution by learning optimal test-time UI and KG transformation distribution, named TTA-GREC, which aims to improve performance through test-time graph data transformation, thereby achieving better generalization for GNNs. As shown in Figure 2, our TTA-GREC is composed of three main modules: (1) Pseudo-label guided UI graph transformation for adaptive improvement: This module dynamically adjusts the test-phase user-item interaction graph by generating pseudolabels, pruning noisy edges, and performing adaptive edge sampling. It enhances the semantic structure of the interaction graph by focusing on critical relationships, thus mitigating distribution shifts caused by unseen interactions during testing; (2) Rational score guided KG graph revision for semantic enhancement: Rationality scores are computed by combining entity and relation embeddings, guiding selfsupervised tasks such as edge masking and refactoring to enhance semantics and refine the user-item graph. These tasks enable robust adaptation to noisy test data by learning meaningful representations without supervised labeling; (3) Sampling-based self-supervised adaptation for contrastive learning: By constructing positive and negative sample pairs, this module leverages contrastive learning to align user and item representations. It reduces noise interference and ensures the semantic consistency of embeddings across testtime data variations, improving the robustness and generalization of test-time recommendation. More detailed modular designs of our proposed TTA-GREC are presented below.
3.2 Modular Design
Pseudo-label Guided UI Graph Transformation. We have three components in this module: (a) Simulate potential interaction; (b) Attention scoring and edge sampling; and (c) Graph augmentation strategy.
(a) Simulate potential interaction. Given a set of M test users U te = {ute 1 , ute 2 , · · · , uteM } and a set of all N items V = {v1, v2, · · · , vN}, there are no pre-labeled interaction relationships yuv between these test users and items. To construct a new test graph, use the trained KGNNθ∗ model to predict the p items that each user u ∈ U te is most likely to interact with, generating a test item set V te = {vte 1 , vte 2 , · · · , vte p }. These predicted interaction relationships serve as pseudolabels yte uv , describing the potential interactions between users and items. Finally, we combine the test user set, the test item set, and the pseudo-labels into a new test graph G te ui = (U te , V te , yte uv ).
(b) Attention scoring and edge sampling. The attention score α(u,v) of user-item interactions is calculated based on user and item embeddings and edge features in the interaction graph. Given a test graph G te ui = (V,Eui), where V is all the nodes of the original graph and Eui is the set of edges. For each user-item interaction edge Eui, obtain the user embedding eu = fu(G te ui , u) and the item embedding representation ev = fu(G te ui , v). Based on the embeddings of users and items, as well as the edges Eui of the interaction graph, calculate the attention score α(u,v) to measure the degree of user attention to each item:
During the inference (testing) stage, these attention scores can be aggregated or averaged to identify which interaction pairs are most significant for user preferences. The attention score can be further normalized:
To increase the diversity of sampling, a double logarithmic transformation noise perturbation ϵ is used, the Gumbel distribution is introduced to enhance exploration, and finally the perturbed sampling probability distribution P(e) is obtained:
Sampling is performed based on this probability distribution P(e) to obtain the edge set Esample, and then a new user-item interaction enhanced graph G+ ui = (V,Esample) is constructed. By retaining edges with high attention and discarding edges with low attention, the model can adaptively streamline the graph structure, making the user-item interaction graph closer to the real preference relationships.
(c) Graph augmentation strategy. The enhanced user-item interaction graph G+ ui is input into the GCN of the KGNNθ∗ model to update node embeddings, and by optimizing the similarity between user embedding vectors and positive sample item embedding vectors while increasing the distance between user embedding vectors and negative sample item embedding vectors, thereby improving recommendation performance.
The calculation of the user embedding eu and the item embedding ev is updated through the graph neural network layers in the optimized interaction graph G+ ui . The embedding update formula is:
where N(u) is the neighbor set of user u; W(l) is the weight matrix of the l-th layer; σ is the activation function.
Rational Score Guided KG Graph Revision. We have two components in this module: (a) Rational scoring function; and (b) Adaptive masking and reconstruction.
(a) Rational scoring function. The importance of the semantics and relationships contained in different triples (h, r, t) in the knowledge graph may vary significantly. Different user preferences for similar products may be influenced by various complex relationships. Hence, the design goal of the rational weighting function is to enhance the role of reliable relationships while suppressing the negative impact of potential noise and low-correlation relationships on model performance. Inspired by the Heterogeneous Graph Transformer (HGT) [Hu et al., 2020], we propose the rational weighting score y(h, r, t):
Here, eu and et are the embeddings of the head node and the tail node, respectively, W is a linear projection matrix Rd×d , where d is the hidden dimension, ⊙ is the element-wise dot product used to fuse the relationship embedding er, Softmaxh indicates the normalization of all edges of the head node h, and deg(h) is the degree of the head node h.
(b) Adaptive masking and reconstruction. Given a knowledge graph Gkg = (E,Ekg), its edge set is defined as Ekg = {(h, r, t)|h ∈ E, t ∈ E, r ∈ R}. Edges with high attention scores are usually more important in semantic expression. By masking these high-importance edges, the model can extract potential structures and relationships from secondary edges when key semantic information is missing. Add noise ϵ to the rational score y(h, r, t) for perturbation and select the top k edges with the highest scores for masking:
The noise ϵ = - log(- log(U)), where U ∼ Uniform(0, 1).
The set of high-attention edges Etop is obtained:
Masking only high-attention edges may cause the model to focus too much on prominent features. To avoid the model focusing too much on prominent features and ignoring potential long-tail features, a randommask Randomk covering the entire graph is further introduced:
Combining the high-attention edge mask and the random mask, the final mask set is obtained:
We convert the original knowledge graph Gkg into a new graph structure G+ kg = (E, Enew), where Enew = Ekg \ Emask. On the new graph G+ kg , the head node embedding eh = fk(G+ kg , h) and the tail node embedding et = fk(G+ kg , t) are calculated, and these embeddings are used to optimize the objective function.
Sampling-based Self-supervised Adaptation. We have two components in this module: (a) Adaptive sampling; and (b) Latent space projection.
(a) Adaptive sampling. We dynamically select representative UI and KG edges based on the attention scores of the edges to enhance the learning effect of the model, respectively. Adaptive sampling of KG edges filters out edges with higher rational weighting scores y(h, r, t) in Topk (y(h, r, t)) to retain important relationship information while discarding edges with low correlation. Given the knowledge graph Gkg = (E, Ekg), create a Boolean mask
The retained edge indices E′kg and their types T ′ kg are selected through the mask Mkg:
Adaptive sampling of UI edges uses the average attention α(u,v) of items as the basis of the sampling probability P(e)
to ensure that edges with high attention are more likely to be retained. The sampled edges according to probability:
To maintain the average of the overall weight, adjust the weight of the sampled edges:
where ϕ represents the edge drop rate, the number of retained edges is k = ⌊(1-ϕ)×|E|⌋, Wui is the original edge weight. (b) Latent space projection. In our proposed TTA-GREC, a two-layer multi-layer perceptron (MLP) is used to perform nonlinear transformation on the embedding vectors, thereby enhancing the expressive ability of embedding representation and the effect of contrastive learning. First, the GCN of the KGNNθ∗ model is used to encode the user-item interaction graph and the knowledge graph, respectively, to obtain enhanced item embedding vectors:
To align the embedding vectors in the user-item interaction graph and the knowledge graph, this paper uses a two-layer multi-layer perceptron (MLP) to map the embedding vectors into the latent space. The specific process is as follows:
Through the nonlinear transformation of the above twolayer MLP, the embedding vectors are mapped into the latent space to form more expressive and discriminative representations.
3.3 Optimization Objective
Mask Reconstruction Loss Lmae. The rationale for this process is that by filtering out critical and randomly important edges through the masked edge set, the new graph structure can more effectively capture the core semantic information in the knowledge graph while reducing the interference of noise and irrelevant relationships, thereby improving the recommendation performance and generalization ability of the model. After masking, the goal of the model is to recover the masked information as much as possible. The masked edges are reconstructed using a dot product decoder, and the reconstruction optimization objective of the masked edges is defined as follows:
where r′ = ⟨eh, et ⊙ r⟩, and σ(·) represents the sigmoid function.
Recommendation Loss Lrec. In the user-item interaction graph dynamic optimization module, the recommendation loss is used to optimize the relationship between user embeddings and item embeddings of positive and negative samples. The optimization function is defined as:
where D is a set of triples containing users, positive samples, and negative samples. Through the graph augmentation strategy, the structure of UI graph is more in line with real user preferences.
Contrastive Learning Loss Lcl. The objective of the optimization function is to maximize the similarity between positive samples and minimize the similarity between positive and negative samples through contrastive learning. To construct negative sample pairs, a random permutation method is used to generate negative sample indices j, thus forming negative sample pairs of (zui i , zkg j ) and (zui j , zkg i ). We adopt InfoNCE-based contrastive loss function as follows:
Here, sij = cos(zui i , zkg j ), cos(·) is the cosine similarity and τ is the temperature parameter.
The total loss function of the model can be expressed as:
By minimizing Ltotal, the model can jointly improve recommendation performance and generalization ability in three aspects: knowledge graph enhancement, user-item interaction optimization, and contrastive learning.
4 Experiment
In this section, we answer several research questions related to TTA-GREC through experiments: Q1: How does the proposed TTA-GREC perform on pre-trained KGNNs for recommendation tasks under different test-time graph distribution shifts? Q2: How do different submodules and learning strategies in TTA-GREC contribute to its performance? Q3: How sensitive is TTA-GREC to hyperparameter settings? Q4: How does TTA-GREC perform in terms of runtime efficiency and visualization?
4.1 Experimental Settings
Datasets. We utilize three different datasets: Last-FM, MIND, and Alibaba-iFashion, which respectively represent different domains of recommendation systems. Last-FM [Wang et al., 2019; Zhao et al., 2019]: It is a dataset of usermusic interaction logs with rich metadata. MIND [Tian et al., 2021]: It is a news recommendation dataset with complex user-item interactions and semantic content. AlibabaiFashion [Wang et al., 2021]: It is a dataset focused on fashion product recommendations, featuring dynamic user preferences and detailed item attributes. We follow the procedures and partitions in previous works [Wang et al., 2019; Tian et al., 2021; Wang et al., 2021; Yang et al., 2023]. More statistical information of datasets is listed in the Appendix.
Test-time Evaluation Protocol. For each KGNN model, we follow a standard training pipeline and train it on the training set until it achieves the best performance on the validation set in terms of recommendation. These 'well-trained' GNN models remain fixed during the entire test-time adaptation process, ensuring that no model parameters are updated during testing. To ensure a fair comparison, we maintain consistent settings in all baselines and TTA-GREC. All evaluations are conducted under a full-ranking setup, and average performance across multiple runs is reported to ensure reliability. We evaluate performance using Recall@N and NDCG@N, with N = 20, to assess the model's capability in generating top-N recommendations effectively.
| Dataset | Method | KGIN | KGCL | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Recall | NDCG | Precision | Hit Ratio | Recall | NDCG | Precision | Hit Ratio | ||
| Last-FM | Baseline-TT | 0.0873 | 0.0766 | 0.0357 | 0.3595 | 0.0971 | 0.0888 | 0.0405 | 0.3760 |
| Dropedge-TT | 0.0707 | 0.1511 | 0.0578 | 0.3634 | 0.1670 | 0.1850 | 0.0773 | 0.5099 | |
| Featmask-TT | 0.0713 | 0.1205 | 0.0569 | 0.3837 | 0.2857 | 0.3008 | 0.1411 | 0.7468 | |
| TTA-GREC (Ours) | 0.0911 | 0.2191 | 0.0969 | 0.5319 | 0.2877 | 0.3054 | 0.1433 | 0.7517 | |
| MIND | Baseline-TT | 0.0340 | 0.0212 | 0.0107 | 0.1795 | 0.0338 | 0.0209 | 0.0090 | 0.1573 |
| Dropedge-TT | 0.0301 | 0.0808 | 0.0207 | 0.3704 | 0.1228 | 0.1065 | 0.0548 | 0.5295 | |
| Featmask-TT | 0.0281 | 0.0586 | 0.0141 | 0.2666 | 0.2211 | 0.1791 | 0.0849 | 0.7471 | |
| TTA-GREC (Ours) | 0.0348 | 0.0564 | 0.0309 | 0.3497 | 0.2161 | 0.1757 | 0.0839 | 0.7369 | |
| Alibaba-iFashion | Baseline-TT | 0.1172 | 0.0732 | 0.0196 | 0.3238 | 0.1270 | 0.0801 | 0.0213 | 0.3464 |
| Dropedge-TT | 0.0894 | 0.1733 | 0.0273 | 0.5192 | 0.2387 | 0.1501 | 0.0377 | 0.5637 | |
| Featmask-TT | 0.1072 | 0.2141 | 0.0317 | 0.5869 | 0.2255 | 0.1394 | 0.0356 | 0.5399 | |
| TTA-GREC (Ours) | 0.1295 | 0.2526 | 0.0409 | 0.7035 | 0.2387 | 0.1491 | 0.0377 | 0.5640 | |
BaselineMethods. To evaluate the effectiveness of the proposed TTA-GREC, we compare it with the following three groups of baseline methods: (a) Knowledge graph-enhanced recommenders: we use a Baseline-TT setting where the model is traditionally trained, and the fixed model parameters are directly applied during the test phase without modification to the test data; (b) Graph structure based self-supervised learning: DropEdge [Rong et al., 2019] is a widely used graph data augmentation method that randomly removes edges during the training process. We apply DropEdge-TT to modify the UI graph during the test phase. The resulting embeddings are passed to the contrastive learning module for predictions; (c) Graph feature based self-supervised learning: NodeFeatureMask [Mishra et al., 2020] is a feature-level enhancement that randomly masks node features. We design a Featmask-TT approach where feature masking is applied to UI embedding during the test phase and subsequently used for contrastive learning.
4.2 Experimental Results
Performance of Test-time Recommendation. To evaluate the effectiveness of the proposed test-time adaptation framework TTA-GREC, we compare its performance with baseline methods across multiple datasets, as shown in Table 1. Across all datasets, the proposed TTA-GREC outperforms all baseline methods on key metrics for both KGIN and KGCL models. On Last-FM, TTA-GREC achieves a Recall of 0.0911 and 0.2877 for KGIN and KGCL, respectively, representing a relative improvement of 4.36% and 0.70% over the best-performing Featmask-TT. On MIND, while FeatmaskTT slightly surpasses TTA-GREC in Recall for KGCL, TTAGREC still achieves competitive results across NDCG, Precision, and Hit Ratio. For example, TTA-GREC produces an NDCG of 0.0564 for KGIN, which outperforms BaselineTT and Dropedge-TT. On Alibaba-iFashion, TTA-GREC demonstrates superior performance, particularly in metrics that highlight overall recommendation quality. For KGIN, it achieves a Hit Ratio of 0.7035, surpassing Featmask-TT. For KGCL, TTA-GREC yields consistent improvements in Precision and NDCG.
| Dataset | Model | Recall | NDCG |
|---|---|---|---|
| Last-FM | TTA-GREC (Ours) w/o UI transformation w/o KG revision w/o CL | 0.0911 0.0814 0.0707 0.0890 | 0.2191 0.1520 0.1511 0.1761 |
| MIND | TTA-GREC (Ours) w/o UI transformation w/o KG revision w/o CL | 0.0348 0.0139 0.0301 0.0265 | 0.0564 0.0187 0.0808 0.0470 |
| Alibaba-iFashion | TTA-GREC (Ours) w/o UI w/o KG revision | 0.1295 0.1175 | |
| w/o CL | 0.0894 | 0.2526 0.1597 0.1733 | |
| transformation | |||
| 0.1137 | 0.1788 |
In summary, the self-supervised edge masking and reconstruction strategies employed in our framework mitigate the effects of data sparsity and improve semantic embedding quality. This explains the significant improvements in NDCG for datasets with rich KG information. By constructing positive and negative sample pairs, TTA-GREC introduces additional supervision signals, which reduce noise interference and improve the discriminability of embeddings. This adaptation is particularly effective in dynamic scenarios, where user preferences frequently change.


Ablation Study of TTA-GREC. To evaluate the contribution of each submodule in TTA-GREC, we conduct ablation studies by sequentially removing: (I) w/o UI transformation: Removes UI graph transformation with only the original test UI list. (II) w/o KG revision: Removes KG transformation by only origanal KG embedding. (III) w/o CL: Removes sampling-based contrastive learning by the Euclidean distance of the embedding. We report the results of the ablation study in Table 2 and draw the following observations: First, removing the UI transformation module leads to a significant decline in Recall and NDCG. This indicates that this module is crucial to refining user-item interactions, eliminating noise, and optimizing key interactions. Second, removing the KG revision module has the most significant impact on the NDCG of all datasets, for example, it drops by more than 30% on Alibaba-iFashion. This highlights the critical role of this module in improving knowledge graph embeddings, enriching semantic information, and alleviating data sparsity. Lastly, removing the CL module has a relatively small impact on Recall and NDCG, but there is a significant decline on all datasets, which verifies its value in further enhancing the robustness and discriminability of the model through contrastive learning.
Hyper-parameter SensitivityAnalysis. The results in Figures 3 and 4 highlight the impact of mask size and temperature parameter on Recall and NDCG. Figure 3 shows the effect of different mask sizes on Recall and NDCG. The main observations are as follows: the best performance is achieved with a mask size of 128. This indicates that smaller mask sizes are effective in retaining key semantic information while introducing enough noise for robust representation learning. Both metrics continue to decline as the mask size increases to 256 and larger. This suggests that too large a mask may result in excessive information loss, reducing the model's ability to generate high-quality embeddings. Figure 4 shows the effect of different values of τ on Recall and NDCG. We observe that both Recall and NDCG reach their highest values when τ = 0.1. This indicates that smaller temperatures can effectively balance the positive and negative sample distributions, improving contrastive learning performance. When τ exceeds 0.2, both metrics show a significant decrease. This means that a too high value of τ reduces the effectiveness of negative sampling.
| Model | Dataset | Train Time (s) | Test Time (s) |
|---|---|---|---|
| Last-FM | 421.82 | 421.82 | |
| KGIN | MIND Last-FM | 851.84 | 851.84 354.67 |
| Alibaba-iFashion | 354.67 | ||
| 296.13 | 296.13 | ||
| DropEdge-TT | MIND | 2035.77 | 2035.77 |
| Alibaba-iFashion | 1209.93 | 1209.93 | |
| Last-FM | 164.21 | 164.21 | |
| Featmask-TT | MIND | 1130.28 | 1130.28 |
| Alibaba-iFashion | 733.45 | 733.45 | |
| Last-FM | 488.17 | 488.17 | |
| TTA-GREC (Ours) | MIND | 712.63 | 712.63 |
| Alibaba-iFashion | 895.56 | 895.56 |
Running Time Comparison. Table 3 shows the training and testing times for each model. Details on KGCL are provided in the Appendix. For each method, we run the experiments until the best hyperparameters are obtained, and the report training and testing times are averaged over multiple runs. TTA-GREC achieves competitive runtime efficiency across all datasets. While TTA-GREC exhibits a moderate increase in runtime compared to lightweight models like KGIN, it significantly outperforms more computationally expensive models such as DropEdge. TTA-GREC's runtime efficiency is evident in its ability to provide test-time adaptation with minimal computational overhead. Its testing time on larger datasets, such as Alibaba-iFashion, demonstrates its scalability.
5 Conclusion
We first propose a Test-Time Adaptation framework for Graph-based Recommender system, named TTA-GREC, to address the key issue of distribution shift between training data and test data. The framework adopts a data-centric approach. TTA-GREC achieves test-time adaption through three core components: (1) Pseudo-label guided UI graph transformation for adaptive improvement, (2) Rational score guided KG graph revision for semantic enhancement, and (3) Sampling-based self-supervised adaptation for contrastive learning. Experiments conducted on public datasets demonstrate the effectiveness of the method. In the future, we will focus on more efficient TTA strategies to enhance the realtime use of online recommender systems.
Acknowledgments
This work is supported by the Major Program of the National Social Science Foundation of China under Grant No.19ZDA127.
@inproceedings{ijcai2025p510,
title = {Test-Time Adaptation on Recommender System with Data-Centric Graph Transformation},
author = {Liu, Yating and Zheng, Xin and Li, Yi and Guo, Yanqing},
booktitle = {Proceedings of the Thirty-Fourth International Joint Conference on
Artificial Intelligence, {IJCAI-25}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {James Kwok},
pages = {4579--4587},
year = {2025},
month = {8},
note = {Main Track},
doi = {10.24963/ijcai.2025/510},
url = {https://doi.org/10.24963/ijcai.2025/510},
}
TY - CPAPER TI - Test-Time Adaptation on Recommender System with Data-Centric Graph Transformation AU - Liu, Yating AU - Zheng, Xin AU - Li, Yi AU - Guo, Yanqing T2 - Proceedings of the Thirty-Fourth International Joint Conference on Artificial Intelligence, IJCAI-25 PB - International Joint Conferences on Artificial Intelligence Organization PY - 2025 SP - 4579 EP - 4587 DO - 10.24963/ijcai.2025/510 UR - https://doi.org/10.24963/ijcai.2025/510 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: