CoLES: Contrastive learning for event sequences with self-supervision

Dmitrii Babaev, Nikita Ovsov, Ivan A Kireev, Gleb Gusev, Maria Ivanova, Alexander Tuzhilin · DOI

Abstract

Self-supervised learning has revolutionized computer vision and natural language processing, yet its application to discrete event sequences—such as financial transactions or clickstreams—remains challenging due to a lack of local context sensitivity. We present CoLES (COntrastive Learning for Event Sequences), a framework that utilizes a novel "Random Slices" augmentation strategy to generate high-quality embeddings. By treating user event histories as latent classes, CoLES trains an encoder to minimize the distance between sub-sequences from the same user while maximizing the distance between different users. Evaluation across five public datasets and a large-scale industrial deployment demonstrates that CoLES consistently outperforms hand-crafted features and existing self-supervised baselines, generating significant annual value in financial applications.

Introduction

In modern data science, the ability to extract meaningful representations from raw data without extensive labeling is a significant advantage. While models like BERT and SimCLR have set benchmarks in NLP and CV, discrete event sequences present unique hurdles. Unlike pixels in an image, individual transactions are often independent of their immediate neighbors, making traditional context-based self-supervision less effective. Historically, practitioners relied on labor-intensive "hand-crafted features," which often fail to capture complex, non-linear patterns. CoLES addresses this by bringing the power of contrastive learning to the domain of event sequences.

Methodology

The CoLES framework operates in two primary phases: a self-supervised pre-training phase and a downstream task adaptation phase.

Random Slices Augmentation

The core of CoLES is the "Random Slices" strategy. To create positive pairs for contrastive learning, the algorithm samples two random sub-sequences (slices) from a single user's event history. These slices may overlap or be temporally distant, allowing the model to learn a global representation of user behavior rather than just local transitions.

Contrastive Learning and Architecture

The model is trained to pull embeddings of slices from the same user closer together in vector space while pushing slices from different users apart. The architecture consists of:

  1. Event Encoder: Linear layers with batch normalization that transform transaction attributes into vectors.
  2. Sequence Encoder: A Gated Recurrent Unit (GRU) that aggregates these vectors into a fixed-length user embedding.
  3. Hard Negative Mining: To improve learning efficiency, the model identifies "negative" examples (different users) that are currently mapped close together and explicitly forces them apart.
The CoLES framework: Phase 1 shows contrastive pre-training using random slices, while Phase 2 illustrates downstream application via LGBM or a fine-tuned head network.

Datasets and Evaluation

CoLES was validated on five diverse public competition datasets, including Age Group Prediction (44M transactions), Churn Prediction (1M transactions), and Credit Scoring (443M transactions). Furthermore, the system was deployed at a major European bank, processing data for 10 million corporate and 5 million individual clients.

Key Insights

The Periodicity Assumption

A fundamental assumption of CoLES is that event sequences are "repeatable" enough that random slices from the same user share a latent signature. The authors validated this by measuring the KL-divergence between distributions of slices, proving that slices from the same user are significantly more similar than those from random users.

Histogram of KL divergence showing that slices from the same client are significantly more similar than those from random clients, supporting the periodicity assumption.

Learning vs. Hand-Crafting

CoLES proved particularly effective for complex entities like legal corporations, where human intuition often fails to design adequate features. By learning representations directly from raw sequences, CoLES captured patterns that domain experts missed, leading to its biggest relative gains in corporate banking tasks.

Results and Impact

CoLES consistently achieved state-of-the-art performance, surpassing baselines like Contrastive Predictive Coding (CPC) and Next Sentence Prediction (NSP). When used as inputs for Gradient Boosting models (e.g., LightGBM), CoLES embeddings outperformed expert-designed features. In production, the framework has generated hundreds of millions of dollars in annual value through improved fraud monitoring and credit lead generation. Additionally, the authors employed quantization to compress 1KB embeddings to 128 bytes with minimal accuracy loss, facilitating large-scale industrial deployment.

Conclusion

CoLES demonstrates that contrastive learning is highly effective for discrete event sequences when paired with appropriate augmentation strategies. While the current model excels at capturing behavioral snapshots, future work will focus on modeling irregular time intervals between events and developing dynamic embeddings that evolve in real-time as new transactions arrive.

Summary updated

BibTeX
@inproceedings{babaev2020coles,
  author = {Dmitrii Babaev and Nikita Ovsov and Ivan A Kireev and Gleb Gusev and Maria Ivanova and Alexander Tuzhilin},
  title = {{CoLES: Contrastive learning for event sequences with self-supervision}},
  booktitle = {SIGMOD},
  year = {2020},
  doi = {10.1145/3514221.3526129},
}
Figure