Problem
Banks usually turn transactions, app events and support logs into hand-built tabular features for risk, fraud and offer models. This is slow, and aggregates lose the order and timing of a customer's behavior. Nubank wanted a model that reads the raw history directly, since even a small gain in a core model brings real value. One model should also serve several products.
Example from the article: Nubank trained a transformer called nuFormer on transaction sequences and deployed it to production to solve credit in Brazil. It also showed offline lifts in lending, income prediction and cross-sell.
Solution in brief
Write each transaction as a few tokens (amount sign, amount bucket, date parts, tokenized description), concatenate a customer's transactions into one sequence and pretrain a transformer on it. Then fine-tune the whole model with task labels and blend in tabular features. Choose data sources and history length as hyperparameters, tested offline.
Questions this case answers
- How to learn a reusable representation of an entity from long event sequences with mixed numeric, categorical and text attributes, instead of hand-engineering aggregate features
- How to choose the data sources, history length and model size for a sequence model when attention cost grows quadratically with context
- How to replace hand-built tabular features with a model that learns from a customer's raw transaction history?
- How to turn a bank transaction into tokens a transformer can read without an ID for every transaction type?
Tools and methods
- Transaction tokenization — amount sign, binned amount, month, day and weekday tokens plus a BPE-tokenized description.
- Pretraining (next token prediction or masked language modeling) — learns user embeddings from the sequences.
- Supervised fine-tuning with a linear head — predicts the task label from the final token embedding.
- Gradient-boosted trees on frozen embeddings — the first evaluation, which showed limited signal.
Google or a one-time email code. No password.