TFMLab

How it’s built

How our TFM uses 62 Transformer upgrades

For each design decision: how the technique evolved, what our transaction foundation model uses, why, and why not the alternatives. Pick a use case to see what changes. The 62 upgrades, narrated →

Our TFM usesConsidered, not usedPart of the evolution

Input

Reading one transaction

  1. 2020 Field attention + pooling

Our TFM uses: Field attention + pooling

A transaction is a row of fields (amount, merchant, time). Attention across its fields, pooled into one vector, lets the sequence model see one event per step.

Fraud detection
Fields like merchant category, channel and device carry the signal; field attention learns their combinations.
Product recommendation
Item id and timestamp are the only fields, so the field step is small.
Credit risk
Balances, payments and limits sit in one event; pooling keeps the history short.
Money laundering
Counterparty, amount and country fields; we expect their combinations to help flag structuring.

Input & position

Event order and time

  1. 2017 Sinusoidal position encoding
  2. 2018 Relative position representations
  3. 2021 RoPE
  4. 2021 ALiBi
  5. 2023 Position Interpolation
  6. 2023 YaRN
  7. 2023 Time gap + calendar fields
  8. 2026 T-RoPE

Our TFM uses: RoPE + Time gap + calendar fields

RoPE encodes the order of events; real time (gaps, day, month) goes in as fields, both as a token and as a number. In our tests, replacing RoPE by time-aware T-RoPE gave no gain on ML-20M or Pixel200K.

Why not

  • Sinusoidal position encoding Absolute positions extrapolate poorly to longer histories.
  • ALiBi A fixed recency bias; the time-gap fields already tell the model how recent each event is.
  • T-RoPE No gain over RoPE plus time fields in our two-layer TFM (paper, Section 6).
  • YaRN Only needed to stretch a trained model to longer histories; we train at the length we serve.
Fraud detection
Seconds-to-minutes gaps matter: a burst of payments is the signal, so the gap token is key.
Product recommendation
The date matters: on Amazon Books, giving our two-layer TFM the date as a field lifted HR@10 by 12% (8.31 vs 7.39).
Credit risk
Calendar fields (month-end, payday) capture repayment cycles.
Money laundering
Long, periodic gaps (weekly structuring, dormant accounts) favour continuous gaps plus calendar.

Attention

Attention over the history

  1. 2019 Sparse Transformer
  2. 2020 Longformer
  3. 2020 Linear attention
  4. 2022 FlashAttention
  5. 2023 Mamba
  6. 2024 Gated DeltaNet
  7. 2025 NSA
  8. 2025 DSA
  9. 2025 Qwen3-Next hybrid

Our TFM uses: Longformer + FlashAttention

Causal attention over a sliding window of recent events (64 to 128; Longformer’s window, without its global tokens), run with FlashAttention: recent behaviour carries most of the signal, and the cost stays fixed per event.

Why not

  • Linear attention Constant-cost state, but weaker recall of a specific past event; we expect it to pay off past ~10k events.
  • Mamba Strong for streaming, but recall of exact past transactions is weaker than attention.
  • NSA Built for very long contexts; our sequence lengths (256 to 2,048 events) don't need it yet.
  • Sparse Transformer Fixed strides; learned sparsity (NSA, DSA) superseded it.
Fraud detection
A short window of the latest events: what just happened decides the score.
Product recommendation
50 to 200 recent items, full causal attention inside the window.
Credit risk
Months of history: a longer window; hybrids become worth testing at thousands of events.
Money laundering
Multi-year histories: sparse or hybrid attention (NSA, Gated DeltaNet) is the next step, not yet our default.

Attention: KV & heads

Keys, values and serving

  1. 2019 MQA
  2. 2023 GQA
  3. 2023 PagedAttention / vLLM
  4. 2024 MLA
  5. 2024 YOCO

Our TFM uses: GQA

Grouped-query attention (4 query heads per key-value head) with a KV cache: about four times less memory per customer than full multi-head attention, with little expected quality loss.

Why not

  • MQA One shared key-value head saves more memory but loses more quality.
  • MLA Compresses the cache further, but adds complexity that pays off mainly in very large models.
Fraud detection
Scored at authorisation in milliseconds: the cache lets each new payment reuse the history.
Product recommendation
Session scoring benefits from the cache; batch scoring needs it less.
Credit risk
Scored monthly in batch: the cache matters little.
Money laundering
Batch investigation: cache size is not the bottleneck.

Normalization

Normalization and stability

  1. 2019 Pre-LN
  2. 2019 RMSNorm
  3. 2020 QK-Norm
  4. 2022 z-loss
  5. 2025 Gated attention

Our TFM uses: Pre-LN + RMSNorm + QK-Norm + z-loss

Pre-norm RMSNorm, QK-norm and z-loss: cheap insurance against loss spikes from extreme amounts and large field vocabularies.

Why not

  • Gated attention A newer stability gain; a candidate for the next challenge cycle, not yet tested.
Fraud detection
Heavy-tailed amounts: QK-norm keeps attention scores from blowing up.
Product recommendation
Large item vocabularies: z-loss keeps the output logits in range.
Credit risk
Same defaults; stability matters most in long monthly retraining runs.
Money laundering
Same defaults.

FFN, experts & memory

Feed-forward and experts

  1. 2017 Sparsely-gated Mixture-of-Experts
  2. 2020 SwiGLU FFN
  3. 2021 Switch Transformer
  4. 2023 Mixtral 8x7B
  5. 2024 DeepSeekMoE
  6. 2026 Engram

Our TFM uses: SwiGLU FFN

A dense SwiGLU feed-forward: a consistent gain at the same latency, simple to train and serve.

Why not

  • DeepSeekMoE Experts could specialise by merchant or region, but routing adds serving cost; at our sizes a dense model is simpler.
  • Switch Transformer Top-1 routing is the simplest MoE, still more moving parts than a dense block.
Fraud detection
Dense; experts become interesting at card-network scale, across very different merchants.
Product recommendation
Dense.
Credit risk
Dense.
Money laundering
Dense; experts by corridor or country are a future option.

Whole-model design

What it learns from

  1. 2018 GPT
  2. 2018 BERT
  3. 2023 Full-catalogue softmax
  4. 2024 MTP

Our TFM uses: GPT + Full-catalogue softmax

Next-event prediction, causal like GPT: the model scores each event using only the past, as in production. For recommendation, scoring every item (full softmax) instead of 128 sampled ones, with four layers, lifted Pixel200K HR@10 from 12.49 to 18.76 (paper, Table 7).

Why not

  • BERT Masked events read the future while training, a view live scoring never has; good for offline embeddings.
  • MTP Predicting two events at once is an option in the Composer; not yet a tested gain.
Fraud detection
Causal next-event: the same model scores each payment in real time.
Product recommendation
Next item with a full-catalogue softmax: our biggest gain.
Credit risk
Next-event pretraining, then a small default-risk head.
Money laundering
Next-event pretraining; masked-event embeddings are an option for offline investigation.

Training & optimizers

Training recipe

  1. 2014 Adam
  2. 2016 Cosine decay
  3. 2017 AdamW
  4. 2017 Learning-rate warm-up
  5. 2019 BF16 training
  6. 2022 Chinchilla compute-optimal scaling
  7. 2022 µP / µTransfer
  8. 2024 WSD schedule
  9. 2025 Muon

Our TFM uses: AdamW + Learning-rate warm-up + WSD schedule + BF16 training

AdamW with warm-up and a warmup–stable–decay schedule, in bf16, sized at about 1,000 transaction tokens per parameter (Chinchilla’s ~20 is for language).

Why not

  • Cosine decay Our benchmarks used it (the Composer’s earlier default); WSD suits models retrained as new months arrive.
  • Chinchilla compute-optimal scaling Its ~20 tokens per parameter is for language; transaction fields are far more predictable, so we plan at about 1,000.
  • Muon Promising for pretraining cost; adopt once tested against AdamW on our data.
  • FP8 training at scale Pays off for large models on H100-class GPUs; bf16 is simpler at our sizes.
Fraud detection
Retrained often as fraud patterns shift: WSD keeps a stable checkpoint between releases.
Product recommendation
Fixed benchmark runs used cosine decay.
Credit risk
Monthly retraining: WSD.
Money laundering
WSD; sized to the history you hold.

Our choices are the TFM Composer’s recommended design; results are from our benchmarks and our paper; use-case notes are design guidance. Each technique links to its paper.

Ep1: The history of the Transformer: attention to ChatGPT to DeepSeek