Introduction
Large Language Models (LLMs) have demonstrated remarkable capabilities in processing discrete text, yet they struggle to natively represent continuous variables like time. This research provides a systematic study of "temporal tokenization"—the process of converting continuous timestamps into discrete tokens. The study reveals that the optimal strategy for representing time is not universal but depends heavily on the statistical distribution of the underlying event data.
The Challenge of Continuous Time
While LLMs are increasingly applied to event sequence modeling (e.g., user logs, financial transactions), they face a fundamental architectural hurdle. Traditional Temporal Point Processes (TPPs) utilize complex calculus to handle continuous time, but leveraging the reasoning power of an LLM requires converting time intervals into discrete tokens. Current research employs a variety of methods—from simple numeric strings to complex calendar formats—without a clear understanding of which approach is superior for predicting the timing and nature of future events.
Temporal Tokenization Methods
The authors benchmarked five distinct temporal tokenization strategies using a fine-tuned Llama-3.2-1B model (via QLoRA):
- Numeric String: Time is represented as a plain text string (e.g., "0.076"). This relies on the LLM’s pre-existing numeric literacy, though standard tokenizers often fragment these strings into semantically weak pieces.
- Byte Tokenization: Time is treated as a 32-bit float and split into four discrete byte tokens, offering high precision and token efficiency.
- Calendar Tokenization: A semantic approach where timestamps are converted into human-readable tokens like
<|year_2025|>,<|month_10|>, or<|hours_05|>. - Scale Binning: The time range is divided into $K$ uniform bins (linear or log space), with each bin assigned a unique token.
- Residual Scalar Quantization (RSQ): An adaptive, data-driven method using hierarchical K-Means clustering to create a "codebook." It represents time as a sequence of tokens that progressively refine precision.
Datasets and Temporal Distributions
The study utilizes five real-world datasets representing a broad spectrum of temporal characteristics:
- Stack Overflow, Chicago Crime, & US Earthquake: Characterized by smooth, skewed log-normal distributions.
- NYC Taxi: A complex, "mixed-modal" distribution influenced by human patterns like rush hours.
- Amazon Review: Extremely discrete and "spiky," where reviews often occur at specific, recurring intervals.
Key Insights
The Alignment Principle
There is no single "best" tokenizer. Performance is a matter of alignment: if the data is log-normally skewed, a log-based tokenizer is essential. Using a linear tokenizer on log-normal data leads to a significant collapse in predictive performance.
Independence of "What" and "When"
Interestingly, the choice of temporal tokenizer has negligible impact on the LLM's ability to predict the type of the next event. Its influence is almost entirely confined to predicting when the event will occur.
Context Dilution and Ordering
The researchers found that placing time tokens before event type tokens can degrade accuracy. A "Type-Time" ordering is superior, as long temporal sequences can "dilute" the semantic context needed to predict the next event type.
Results and Performance
- Log-based Winners: On skewed datasets like Stack Overflow, RSQ (Log, L4) and Scale Bin (Log) significantly outperformed naive strings, drastically reducing Root Mean Squared Error (RMSE).
- Calendar Robustness: For the human-centric NYC Taxi data, Absolute Calendar tokens (at second resolution) performed best. This suggests that when data follows societal patterns, human-centric tokens allow the LLM to leverage its pre-trained world knowledge.
- Precision vs. Efficiency: While multi-level strategies like RSQ L4 provide superior precision, they require four times as many tokens per event as single-token strategies, presenting a trade-off between accuracy and computational cost.
Limitations and Future Directions
The study focused on models up to 3B parameters; it remains to be seen if larger models (e.g., 70B+) can overcome poor tokenization through increased reasoning capacity. Additionally, the evaluation was limited to next-event prediction. Future work may explore whether continual pre-training on massive event streams can help LLMs develop a more native "sense of time" regardless of the specific tokenization scheme.
Summary updated