Time-Dependent Representation for Neural Event Sequence Prediction

Yang Li, Nan Du, Samy Bengio

Standard neural sequence models often treat events like words in a sentence, focusing purely on their order while ignoring the actual time that passes between them. However, in many real-world applications, timing is just as important as the sequence itself. This paper introduces novel ways to "embed" time directly into event representations and uses the prediction of future event durations as a clever regularization tool to boost overall accuracy.

The Challenge of Continuous Time

Most sequence prediction models, such as those used in Large Language Models, are "time-independent." They care about the order of tokens, but it doesn't matter if the first token occurred a second ago or a year ago.

In the real world, timing is everything. If you are predicting a patient’s next hospital visit or which app a user will open next, the duration of the previous activity and the idle time between events are massive clues. A 30-minute gap after using a navigation app means something very different than a 30-second gap.

The core challenge is that Recurrent Neural Networks (RNNs) are excellent at handling discrete "tokens" but struggle with continuous, high-variance numbers like "seconds elapsed." Simply feeding a raw scalar time value into a model often leads to poor performance because the network cannot easily relate a single number to a high-dimensional event embedding.

Bridging the Gap: Time-Aware Architectures

To solve this, the authors propose two main strategies to bridge the gap between continuous time and discrete event models:

Model architecture showing the Time-Dependent Embedding Layer and Next Duration Regularizer.

1. Time-Dependent Event Representations

Instead of just feeding the model an event (e.g., "Opened Spotify"), the model modifies the event's vector representation based on how much time has passed ($d_t$). The paper introduces two approaches for this:

  • Time Masking: The model learns to generate a "mask" (a vector of values between 0 and 1) based on the duration. This mask is multiplied by the event embedding, essentially "filtering" or contextualizing the event's meaning based on its timing.
  • Event-Time Joint Embedding: Inspired by how humans categorize time (e.g., "a little while" vs. "a long time"), the authors use a soft one-hot encoding. They project the scalar time value into a vector space and apply a softmax to create a "fuzzy" category for the duration. This time-vector is then averaged with the event-vector to create a single, time-aware input.

2. Time as a Regularizer

The authors argue that if a model cannot predict when something will happen, it probably doesn't fully understand what is happening. They introduce a "Next Event Duration" regularizer that forces the model to predict the upcoming time gap. This acts as a multi-task learning objective:

  • Gaussian-based (NLL): Minimizing the error of predicting the exact next duration.
  • Categorical (Cross-Entropy): Projecting the predicted duration into the same "soft" categories used in the joint embedding and penalizing the model if it gets the category wrong.

Experimental Results

The researchers evaluated their methods on five diverse, real-world datasets: MIMIC II (clinical visits), Stack Overflow (user badges), Financial Transactions, App Usage, and Music Recommendation.

Accuracy comparisons across MIMIC II, Stack Overflow, and Financial datasets.

Key Successes

  • Consistent Gains: The proposed methods generally outperformed "NoTime" (a vanilla LSTM) and "TimeConcat" (simply appending time as a raw feature).
  • TimeJoint Wins: The TimeJoint approach was particularly effective, significantly outperforming previous state-of-the-art models like RMTPP on the Stack Overflow and Financial datasets.
  • App & Music Prediction: On the App Usage and Music datasets, the combination of TimeJoint and Cross-Entropy regularization provided the highest precision (e.g., a Precision@1 of 31.53% for apps vs. 30.29% for the baseline).

Limitations and Domain Sensitivity

Interestingly, while the methods worked well on most datasets, they showed little to no improvement on the MIMIC II medical dataset (as seen in the charts above, where NoTime remained highly competitive). This suggests that in some domains, the specific timing of events might be noisier or less predictive than the sequence of the events themselves.

Conclusion

By treating "idle time" as a special kind of event property and tokenizing continuous time into a "soft" embedding, the authors allow RNNs to use their existing machinery for handling high-dimensional patterns. Furthermore, predicting the time of the next event acts as a powerful "hint" during training, helping the model learn more robust hidden states even if the primary goal is only to predict the next discrete action.

Summary updated

BibTeX
@inproceedings{li2018time,
  author = {Yang Li and Nan Du and Samy Bengio},
  title = {{Time-Dependent Representation for Neural Event Sequence Prediction}},
  booktitle = {Workshops @ ICLR},
  year = {2018},
}
Figure