Defining an Interface Between Transaction Data and Foundation Models

Daniel Braithwaite, Hiroto Udagawa22 Apr 2025

Problem

A bank wants one general customer representation from transaction history instead of hand-made tabular features. Transformers need a sequence of embeddings, so every transaction must first become tokens. An ID per unique transaction needs a very large ID space and cannot handle transactions unseen in training (cold start). Writing every attribute out as text avoids that but spends many tokens per transaction, and attention compute grows quadratically with context length.

Example from the article: a transaction with description "NETFLIX.com", amount $32.40 and date 12/05/2023 has to become a short token string a transformer can read.

Solution in brief

Turn each transaction into a short string of special tokens plus the tokenized description: amount sign, amount bucket, month, day and weekday. Concatenate a customer's transactions with separators, truncate at a context limit, and pre-train a transformer with standard language-model objectives. Then extend the context and scale the model, checking each step on four benchmark tasks.

Questions this case answers
  • How to encode a long sequence of structured events with numeric, date and free-text fields into tokens for a transformer without an exploding ID space or cold start
  • How to extend the effective context length of a sequence model under memory limits and verify each change on downstream tasks
  • How to turn a customer's raw transactions into input a transformer can process?
  • How to represent transactions without a huge ID vocabulary and without failing on unseen merchants?

Tools and methods

  • Special-token transaction string — amount sign, binned amount, month, day, weekday as tokens; description tokenized as text (BPE)
  • Masked language modeling (MLM) and next token prediction (NTP) — self-supervised pre-training objectives
  • Sparse attention and chunking — extend the effective context length
  • FlashAttention with NoPE — memory-efficient attention and no positional embeddings in the causal model
  • Supervised fine-tuning — trains the pre-trained model to predict a task label directly
Continue reading — it's free

Google or a one-time email code. No password.