What is a Transformer? Tokens, attention and where it pays #Transformer#Attention#Usecases
The idea in five steps (tokens, vectors, attention, layers, outputs), shown on a sentence and on a customer's payments, then eight use cases with sourced business results, from search to fraud.
Transformer foundationsEncoder architectureUse cases & value
A Transformer reads a sequence of tokens, turns each token into a vector, and lets every token take a weighted mix of the others (attention), so each vector carries its context. Blocks of attention plus a feed-forward layer are stacked; the output is a score or embedding (encoder), the next token (decoder) or a new sequence (encoder–decoder).
The same machine reads payments: in the lab, a $2,400 laptop bought in Lisbon attends to the flight and hotel the customer already paid for, the context a fixed rule misses. Attention weights in the lab are illustrative.
| Use case | Model | Tokens | Reported result | Source |
|---|---|---|---|---|
| Chat & writing | GPT-2 (decoder) | word pieces | one next-word model picks up many tasks | OpenAI, 2019 |
| Search | BERT (encoder) | query words | helps with about 1 in 10 US English searches | Google, 2019 |
| Translation | original Transformer | sentences | 28.4 BLEU English→German, +2 over prior best | Vaswani et al., 2017 |
| Images | ViT | 16×16 patches | on par with CNNs, less training compute | Dosovitskiy et al., 2020 |
| Recommendations | BST (Alibaba) | recent clicks | higher online click-through on Taobao | Chen et al., 2019 |
| Fraud detection | Sardine | card transactions | +68% / +41% detection on unseen issuers vs traditional ML | FinTech Global, 2026 |
| Payment models | Visa TransactionGPT | consumer transactions | about 22% better than the production model | Visa Research, 2025 |
| Network services | Mastercard | anonymised transactions | one model for cyber defence, loyalty, small-business services | TechInformed, 2026 |
Transcript
How does ChatGPT know which "bank" you mean? Here is the sentence: the bank by the river flooded. The same trick can read a week on one card. One card's week: rent, groceries, fuel, digital goods, a pharmacy, travel, a coffee. Then, at three-oh-seven in the morning, nine hundred dollars of electronics lands. Which past payments should judge it? One engine reads both: the Transformer behind ChatGPT. Visa's TREASURE and Razorpay say their payment models use it. By the end, you'll know the Transformer's five parts, what each becomes for payments, and where our TFM reads like BERT or GPT.
Part one: tokens. A Transformer reads its input one piece at a time. Each piece is a token. For text, a token is a word or a piece of one, all from one shared vocabulary. This sentence makes six. One payment, the nine hundred dollars, becomes one token per field: amount, merchant, time, country, channel, device. Each field has its own vocabulary: merchants never share a list with hours. Our base design reads twelve fields from a public dataset, among them amount, category and the hour.
Part two: vectors. A token is only a name. The model computes with numbers. So each token looks up its row in a table that training fills in: a list of numbers, its vector. The same token always starts from the same row, wherever it appears. A payment does the same, field by field, each field in a table of its own. In our design, each field token gets sixty-four learnt numbers. The bars show eight.
Part three: attention, which other words matter for this one. Here, 'bank' could mean money or a riverside. Each word scores every other word, then takes a mix of them. A thicker arc means more weight. 'Bank' looks most at 'river': half of its mix. It adds that mix to what it already was. Now 'bank' carries 'riverside'. A payment gets attention twice. First across its own fields, called field attention: amount, merchant and time read each other, both ways. Then the bridge folds its twelve field vectors into one vector per payment. Second, along the card's payments: the nine hundred dollars reads the earlier week, and only the past. It leans most on the travel booking, twenty-five percent, and the digital goods, fifteen.
Part four: the feed-forward. After attention, one small network works on each token alone. No mixing between tokens here; that was attention's job. It refines what each token now holds, and adds it on. Field by field, then payment by payment. Its inner bend, the activation, gets its own film later this season.
Part five: layers. A block is attention, then the feed-forward, each after a norm: a rescaling to a steady size. Each adds its result to a stream: the vector, carried up from block to block. Stack the blocks, and each reads the one below: context built on context. Our base design: two field-attention layers, the bridge, then four sequence-attention layers. In all, about one point three million learnt numbers.
The same parts can be wired to read in two directions. Two famous models show both. BERT, from Google in twenty eighteen, reads each word with both its left and right context, and learns by filling blanks. GPT, from OpenAI the same year, reads left to right only, and learns by guessing the next word. Our TFM takes from each. Within one payment, its fields read each other both ways, like BERT: they arrive together. Along the card, it reads payments left to right, like GPT. A payment never sees the future. And it learns like GPT: the whole model learns only by guessing the next payment, so it can score payments as they arrive.
Where did it start? In twenty seventeen, the paper Attention Is All You Need built the Transformer for translation. An encoder reads a sentence in one language. A decoder writes it in another, word by word. The decoder must not peek at words it hasn't written yet, so the paper blocks those connections. A year later, GPT kept only the decoder, and BERT only the encoder. Our catalogue lists sixty-two upgrades to how Transformers are built and trained, from twenty fourteen to twenty twenty-six.
To recap: tokens, vectors, attention to mix in context, a feed-forward on each, stacked in layers. What it means for a TFM: ChatGPT's engine, fed fields instead of words, and payments in time order. On the left, the twenty seventeen block. On the right, today's: the same outline, but several parts have changed. What changed, and what does each part cost on a card's history? That is the next episode.
Sources
- Attention Is All You Need — Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser, Polosukhin, NeurIPS 2017
- BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding — Google AI Language, 2018
- Language Models are Unsupervised Multitask Learners (GPT-2) — OpenAI, 2019
- Understanding searches better than ever before — Pandu Nayak, Google, 2019
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale — Dosovitskiy, Beyer, Kolesnikov, Weissenborn, Zhai, Unterthiner, Dehghani, Minderer, Heigold, Gelly, Uszkoreit, Houlsby, Google Research (ICLR 2021), 2020
- Behavior Sequence Transformer for E-commerce Recommendation in Alibaba — arXiv.org, 2019
- Defining an Interface Between Transaction Data and Foundation Models — Daniel Braithwaite, Hiroto Udagawa (Nubank Editorial), Building Nubank, 2025
- Sardine bets on foundation models to outpace fraud rings — FinTech Global, 2026
- TransactionGPT — arXiv, 2025
- Mastercard builds a payments AI model — TechInformed, 2026