Generative Pretraining at Scale: Transformer-Based Encoding of Transactional Behavior for Fraud Detection

Ze-Yu Zhao, Zheng Zhu, Guilin Li, Wenhan Wang, Bo WangarXiv 2023 · DOI

Researchers at Tencent and WeChat Pay have recently explored the application of the "GPT revolution" to the high-stakes domain of financial fraud detection. By treating sequences of user transactions as sentences in a behavioral language, the authors demonstrate that generative pretraining can uncover complex fraudulent patterns that traditional discriminative models often miss.

Introduction

Fraud detection in digital payments is a classic "needle in a haystack" problem characterized by three primary hurdles: token explosion, temporal complexity, and label scarcity. Transactional data is inherently multivariate, involving amounts, timestamps, locations, and channels. Combining these into a single vocabulary creates a massive, sparse state space. Furthermore, fraud is rarely a single isolated event; it is typically a sequence of behaviors that evolve over time. Finally, while platforms process billions of transactions, confirmed fraud cases are extremely rare, making traditional supervised learning difficult due to the lack of positive training examples.

The authors argue that conventional models, such as Gated Recurrent Units (GRU) or BERT-based approaches, either fail to capture long-term dependencies or do not align well with the inherently chronological, "predict-the-next-step" nature of financial behavior.

The Generative Pretraining Framework

To address these challenges, the researchers proposed a framework centered on Generative Pretraining. Unlike BERT, which uses bidirectional masking, this model utilizes a causal (left-to-right) transformer architecture. This alignment with the temporal nature of payments ensures that past behavior influences the prediction of future states.

The overall architecture of the generative pretraining model, showing the flow from input embeddings through a causal transformer to next-action prediction.

To solve the "token explosion" problem, the model embeds different attributes (e.g., amount, channel) separately and then concatenates them into a single behavior vector. This approach maintains manageable dimensionality while preserving granular detail. The core of the training is a Behavior Reconstruction Loss. Instead of predicting a single discrete token, the model is trained to reconstruct the entire multivariate state of the next transaction. It achieves this by splitting the output embedding into multiple spaces to predict different aspects of the behavior simultaneously.

Anomaly Detection and Fine-Tuning

For the specific task of anomaly detection, the authors introduced a novel Differential Convolutional Fine-Tuning stage. This process involves taking the first-order difference of embeddings to remove seasonal noise and highlight sudden fluctuations in user behavior.

The differential feature extraction process followed by a 1D convolutional block to capture local anomalous patterns.

As shown in the figure above, the "diff feature" highlights changes between consecutive time steps ($t_n - t_{n-1}$). This is followed by a 1D convolutional layer with a rectangular kernel to capture local anomalous patterns. Additionally, to improve unsupervised performance, the team employed a SimCSE-style contrastive learning approach, using dropout as a data augmentation technique to help the model learn robust representations without requiring explicit labels.

Large-Scale Implementation and Results

The study utilized a massive internal dataset from WeChat Pay, encompassing data from 200 million users, totaling 15 billion behavior tokens and over 1.3 trillion feature tokens. This scale proves that LLM-style scaling laws apply to transactional behavior as effectively as they do to natural language.

Key results from the evaluation include:

  • Few-Shot Generalization: The model successfully identified new fraud types, such as "Part-Time Job Fraud," using only a few hundred labeled examples, thanks to the deep "grammar" of normal behavior learned during pretraining.
  • High-Precision Detection: In multi-class tasks, the model achieved a 76.2% recall for "Dating Fraud" and a 59.6% recall for "Part-Time Job Fraud."
  • Effective Ranking: In a binary classification task involving 80 million users, the top 1% of accounts flagged by the model captured nearly 20% of all actual fraud cases, representing a significant improvement in filtering efficiency for human investigators.

Conclusion

By shifting from discriminative to generative modeling, the researchers have demonstrated that forcing a model to "predict the next transaction" allows it to learn a more profound representation of normal behavior. When a user deviates from this learned grammar, the anomaly becomes significantly more apparent. While limitations regarding label noise and feature constraints remain, this work sets a new benchmark for applying large-scale transformer architectures to financial security.

Summary updated

BibTeX
@misc{zhao2023generative,
  author = {Ze-Yu Zhao and Zheng Zhu and Guilin Li and Wenhan Wang and Bo Wang},
  title = {{Generative Pretraining at Scale: Transformer-Based Encoding of Transactional Behavior for Fraud Detection}},
  year = {2023},
  eprint = {2312.14406},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.14406},
}
Figure