Abstract
Time encoding is a fundamental component in modeling temporal data, yet traditional methods rely on rigid hand-crafted features or fixed trigonometric functions. This paper introduces LeTE (Learnable Transformation-based Generalized Time Encoding), a framework that parameterizes time encoding as a deep function learning problem. By utilizing learnable Fourier series and B-splines, LeTE captures both complex periodic patterns and irregular non-periodic trends. Empirical results across time-series forecasting, dynamic graph learning, and large-scale financial risk assessment demonstrate that LeTE significantly outperforms existing methods while maintaining high dimensional efficiency and interpretability.
1. Introduction
In machine learning, representing "time" effectively remains a significant challenge. Traditional approaches generally fall into two categories: Hand-Crafted Time Encoding (HCTE), which involves manual feature engineering (e.g., extracting "month" or "day of week"), and Functional Time Encoding (FTE), such as Time2Vec, which utilizes fixed trigonometric functions to capture periodicity.
However, real-world temporal data is rarely perfectly sinusoidal. It often contains irregular trends, abrupt spikes, and complex mixed patterns that rigid sine waves cannot represent. These existing methods often force a "periodic bias" onto non-periodic data or require excessively large embedding dimensions to compensate for their lack of flexibility. To address these limitations, we present LeTE, a novel framework that moves beyond fixed functions to learn the underlying shape of time directly from the data.
2. Methodology: The LeTE Framework
LeTE treats time encoding as a deep function learning problem. Instead of mapping a timestamp to a vector via a fixed non-linear function, LeTE parameterizes the transformation using two flexible mathematical tools:
2.1 Fourier-based LeTE
This component utilizes a Fourier series expansion with learnable coefficients. Unlike standard FTE, which uses a single frequency, Fourier-based LeTE can adjust amplitudes and frequencies across multiple components. This allows the model to capture intricate periodic patterns that go beyond simple oscillations.
2.2 Spline-based LeTE
To handle non-periodic data, LeTE employs B-splines (piecewise polynomials). Splines are exceptionally flexible at fitting local irregularities and long-term trends, providing the "secret sauce" for datasets where time-based behavior is evolving or stochastic rather than strictly cyclical.
2.3 Combined LeTE and Normalization
The most robust implementation of the framework allocates a portion of the embedding dimensions to Fourier functions and the remainder to Splines. This hybrid approach allows the model to capture global cycles and local anomalies simultaneously. The framework also incorporates Layer Normalization and learnable scaling to ensure stable integration across different mathematical outputs.
3. Theoretical and Practical Insights
LeTE introduces several key advantages over traditional encoding methods:
- Mathematical Generalization: The authors demonstrate that traditional FTE (like Time2Vec) is a restricted, special case of LeTE. By learning its parameters, LeTE can revert to a sine wave if the data requires it, but it is not constrained by that form.
- Dimensional Efficiency: Remarkably, a 2-dimensional or 8-dimensional LeTE embedding can outperform a 100-dimensional FTE embedding. Because the complexity is "baked into" the learnable transformation function itself, the model does not require high-dimensional vectors to represent complex temporal relationships.
- Interpretability: LeTE is not a "black box." The learned Fourier and Spline functions for each dimension can be visualized, allowing researchers to see exactly what temporal patterns—such as daily cycles or long-term decay—the model has identified.
- Rescaling Invariance: The framework remains effective regardless of the time scale (seconds, hours, or days), making it a robust, plug-and-play module for various architectures.
4. Experimental Results
The authors evaluated LeTE across diverse domains to prove its versatility:
- Time Series Forecasting: On datasets including ETT, Weather, and Electricity consumption, LeTE achieved a 98% win rate on Mean Absolute Error (MAE) compared to traditional hand-crafted encoding.
- Dynamic Graphs: In link prediction tasks (Wikipedia, Reddit, MOOC), LeTE consistently achieved State-of-the-Art (SOTA) performance. On the MOOC dataset, it significantly improved Average Precision (AP) over standard FTE-based models like TGN and TGAT.
- Financial Risk Control: In a real-world production environment using a Tencent Mobile Payment dataset (26 million transactions), LeTE provided a clear boost in AUC-ROC and Recall for predicting credit default risk, outperforming models that ignored temporal dynamics or used basic FTE.
5. Conclusion and Future Work
LeTE represents a shift in how we approach temporal features, moving from rigid assumptions to learnable flexibility. While the current framework requires manual setting of the ratio between Fourier and Spline dimensions, future research may involve automated architecture searches to optimize this mix. Furthermore, the success of learnable transformations for time suggests that similar approaches could be extended to other continuous feature encodings in deep learning.
Summary updated