Pretraining for Forecasting in Relational Databases
Organizations: Layer 6 AI · University of Toronto
Abstract
Real-world forecasting increasingly relies on asynchronous transaction logs in relational databases rather than uniformly sampled arrays. While relational deep learning (RDL) models can forecast from these complex histories, they are typically trained separately for each specific target and root entity type. We introduce Query-Conditioned Relational pretraining (QCRP), a self-supervised framework that enables a standard RDL backbone to act as a universal forecaster across a database. QCRP generates diverse forecasting objectives using a structured temporal query grammar and interleaves them through a shared conditional predictor. This produces a robust, frozen encoder reusable for downstream tasks via lightweight predictors or a zero-shot interface. Evaluated on large-scale RelBench databases, QCRP learns frozen representations that support competitive forecasting across tasks and entity types. Furthermore, a single unified QCRP model checkpoint is competitive with isolated, entity-specific specialists. We demonstrate promising results for reusing the learned representations from standard RDL backbones for forecasting tasks in relational databases.
Figures & tables
| Rel-Amazon | Rel-HM | |||||
|---|---|---|---|---|---|---|
| Method | u-LTV | i-LTV | u-churn | i-churn | sales | u-churn |
| Supervised | ||||||
| MaskAE | ||||||
| CTR | ||||||
| TVE | ||||||
| TVE+CTR | ||||||
| Amazon | HM | Rank | |||||
| Method | u-LTV | i-LTV | u-C | i-C | Sales | u-C | |
| Griffin | 35.59 | 53.21 | 62.30 | 69.00 | .151 | 60.20 | 10.17 |
| RDBLearn | 14.54 | 48.56 | 67.57 | 82.07 | .064 | 68.05 | 7.58 |
| KumoRFM-2 | 13.92 | 46.99 | 69.10 | 82.17 | .034 | 69.27 | 4.58 |
| RT-PluRel | 13.94 | 43.03 | 71.35 | 83.27 | .040 | 70.44 | 2.00 |
| TabPFN-Rel | 14.36 | 46.77 | 70.86 | 82.80 | .061 | 70.52 | 4.50 |
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
| Rel-Amazon | Rel-HM | |
|---|---|---|
| Customer entities | 1,850,193 | 1,371,980 |
| Product/article entities | 506,012 | 105,542 |
| Review/transaction events | 20,862,040 | 15,453,651 |
| Prediction horizon | 91 days | 7 days |
| First training cutoff | 2008-01-10 | 2019-09-09 |
| Last training cutoff | 2015-07-02 | 2020-08-31 |
| Database | Task | Train | Validation | Test |
|---|---|---|---|---|
| Amazon | user-LTV | 4,708,383 | 409,792 | 351,885 |
| Amazon | item-LTV | 2,707,679 | 166,978 | 178,334 |
| Amazon | user-churn | 4,708,383 | 409,792 | 351,885 |
| Amazon | item-churn | 2,536,014 | 177,689 | 166,842 |
| HM | item-sales | 5,488,184 | 105,542 | 105,542 |
| HM | user-churn | 3,832,692 | 76,556 | 74,575 |
| Component | GraphSAGE | RelGNN |
| Message-passing layers | 2 | 4 |
| Entity representation width | 128 | 256 |
| Aggregation | Mean | Sum |
| Attention heads | — | 16 |
| GNN dropout | 0 | 0 |
| Table encoder layers / hidden width | 4 / 128 | 4 / 128 |
| ID | Scope | Positive class | Test | Pos. (%) |
|---|---|---|---|---|
| P1 | Direct events | max(rating) 5 | 178,251 | 19.0 |
| P2 | Same product | min(rating) 3 | 178,251 | 23.8 |
| P3 | Same customer | price count(rows) 194.8 | 178,251 | 61.6 |
| P4 | Same product | mean(rating; verified=True) 4.5 | 173,674 | 52.7 |
| P5 | Direct events | price count(rows; verified=True) 14.95 | 178,251 | 58.4 |
| P6 | Same customer | min(rating; verified=True) 3 | 174,415 | 33.2 |
| Rel-Amazon | Rel-HM | |||||
| Initialization | user-LTV | item-LTV | user-churn | item-churn | item-sales | user-churn |
| MAE | MAE | AUC | AUC | MAE | AUC | |
| GraphSAGE | ||||||
| Random initialization | ||||||
| Supervised | ||||||
| Masked reconstruction | ||||||
| Rel-Amazon | Rel-HM | |||||
| Initialization | user-LTV | item-LTV | user-churn | item-churn | item-sales | user-churn |
| MAE | MAE | AUC | AUC | MAE | AUC | |
| Masked reconstruction | ||||||
| CTR | ||||||
| TVE-2 | ||||||
| TVE-2+CTR | ||||||
| ID | Random | TVE | Supervised | QCRP |
|---|---|---|---|---|
| P1 | 63.88 | 72.00 | 70.82 | 72.45 |
| P2 | 81.75 | 96.14 | 97.38 | 97.45 |
| P3 | 68.34 | 72.96 | 77.15 | 77.46 |
| P4 | 66.77 | 91.29 | 96.96 | 96.39 |
| P5 | 68.14 | 73.88 | 87.58 | 85.60 |
| P6 | 65.56 | 69.88 | 69.60 | 70.28 |
| Backbone / evaluation | Adaptation | Full model | Trainable |
|---|---|---|---|
| GraphSAGE, holdout | Supervised | M | M |
| GraphSAGE, holdout | Frozen + MLP | — | 16,897 |
| RelGNN, Amazon | Frozen + MLP | 44,396,033 | 66,561 |
| RelGNN, HM | Frozen + MLP | 45,282,817 | 66,561 |
| Encoder deployment | Rel-Amazon | Rel-HM |
|---|---|---|
| Separate supervised or fully finetuned models | 4 | 2 |
| Frozen root-specific models | 2 | 2 |
| Frozen multi-root model | 1 | 1 |
| Root | Pair subset | Query fields | Initial | Trained |
|---|---|---|---|---|
| Product | All within-root | .121 / .263 | .091 / .195 | .525 / .509 |
| Product | Train–train | .125 / .294 | .107 / .222 | .579 / .554 |
| Product | Train–holdout | -.074 / .439 | -.159 / .303 | .443 / .386 |
| Customer | All within-root | .120 / .173 | .106 / .140 | .365 / .439 |
| Customer | Train–train | .108 / .228 | .103 / .192 | .454 / .441 |
| Customer | Train–holdout | .049 / .220 | .007 / .151 | .146 / .394 |
| Root | Binary queries | AUC | Regression queries | |
|---|---|---|---|---|
| Product | 12 | 82.93 | 26 | 0.368 |
| Customer | 12 | 74.74 | 28 | 0.205 |
| Backbone | user-LTV | item-LTV | user-churn | item-churn |
|---|---|---|---|---|
| MAE | MAE | AUC | AUC | |
| GraphSAGE | 17.34 | 50.59 | 68.35 | 81.28 |
| RelGNN | 14.16 | 51.65 | 70.81 | 82.80 |
| ID | Correct query | Shuffled fields |
|---|---|---|
| P1 | 54.88 | 32.72 |
| P2 | 96.39 | 33.71 |
| P3 | 71.95 | 71.94 |
| P4 | 90.59 | 82.16 |
| P5 | 70.78 | 67.32 |
| P6 | 69.70 | 31.77 |
Time Series Forecasting
Time series forecasting predicts future values from ordered observations using statistical, neural, and probabilistic models to support decisions under uncertainty.
See all 966 papers