QKCV Attention: Enhancing Time Series Forecasting with Static Categorical Embeddings for Both Lightweight and Pre-trained Foundation Models
Hao Wang, Baojun Ma
TL;DR
QKCV Attention introduces static categorical embeddings into dot-product attention to better capture category-aware patterns in time-series forecasting. By injecting C into the K stream, and providing three variants (v1–v3) alongside a static covariate encoder, the approach serves as a versatile plug-in for Transformer-based forecasts and pretrained TimeFM models. Empirical results on Meal, Favorita, and M5 show consistent accuracy gains (lower WPE, P50, P90) and substantial memory savings during finetuning, with TFT often achieving the best performance. The work advances practical deployment by enabling efficient fine-tuning of foundation models and offering interpretable insights via shifted feature importances and attention patterns.
Abstract
In real-world time series forecasting tasks, category information plays a pivotal role in capturing inherent data patterns. This paper introduces QKCV (Query-Key-Category-Value) attention, an extension of the traditional QKV framework that incorporates a static categorical embedding C to emphasize category-specific information. As a versatile plug-in module, QKCV enhances the forecasting accuracy of attention-based models (e.g., Vanilla Transformer, Informer, PatchTST, TFT) across diverse real-world datasets. Furthermore, QKCV demonstrates remarkable adaptability in fine-tuning univariate time series foundation model by solely updating the static embedding C while preserving pretrained weights, thereby reducing computational overhead and achieving superior fine-tuning performance.
