Learning Library

← Back to Library

Transformers Power Stripe Fraud Detection

Key Points

  • A recent tweet highlighted that transformer‑based models could serve as universal learning machines, hinting at far‑reaching industry disruption beyond traditional language tasks.
  • Stripe experimented with a transformer architecture for fraud detection, training a self‑supervised network on tens of billions of transactions to embed each payment into a single vector representation.
  • Despite initial skepticism, Stripe found that payment data exhibits grammar‑like structures—sequences and rules—that allow transformers to capture fraud patterns effectively.
  • This approach consolidates many handcrafted fraud‑detection features into a unified model, simplifying the pipeline that previously required separate models for authorization, fraud, and disputes.
  • An anecdotal side note illustrated how user feedback can dramatically alter model behavior, exemplified by a language model that stopped responding in Croatian after negative ratings from Croatian users.

Full Transcript

# Transformers Power Stripe Fraud Detection **Source:** [https://www.youtube.com/watch?v=-igxoH9mPeE](https://www.youtube.com/watch?v=-igxoH9mPeE) **Duration:** 00:10:27 ## Summary - A recent tweet highlighted that transformer‑based models could serve as universal learning machines, hinting at far‑reaching industry disruption beyond traditional language tasks. - Stripe experimented with a transformer architecture for fraud detection, training a self‑supervised network on tens of billions of transactions to embed each payment into a single vector representation. - Despite initial skepticism, Stripe found that payment data exhibits grammar‑like structures—sequences and rules—that allow transformers to capture fraud patterns effectively. - This approach consolidates many handcrafted fraud‑detection features into a unified model, simplifying the pipeline that previously required separate models for authorization, fraud, and disputes. - An anecdotal side note illustrated how user feedback can dramatically alter model behavior, exemplified by a language model that stopped responding in Croatian after negative ratings from Croatian users. ## Sections - [00:00:00](https://www.youtube.com/watch?v=-igxoH9mPeE&t=0s) **Untitled Section** - - [00:03:32](https://www.youtube.com/watch?v=-igxoH9mPeE&t=212s) **Embedding Payments in High‑Dimensional Space** - The speaker explains how Stripe leverages transformer‑generated vector embeddings to cluster related transactions, revealing hidden fraud patterns that outperform traditional machine‑learning and human analysis. - [00:07:23](https://www.youtube.com/watch?v=-igxoH9mPeE&t=443s) **Transformers Disrupt Payment Fraud Detection** - The speaker explains how Stripe’s transformer‑based foundation model boosted card‑testing attack detection from 59% to 97% and argues that similar models could revolutionize other payment tasks and any industry with hidden sequential semantics. ## Full Transcript
0:00What if transformer-based models were 0:03universal learning machines? We had an 0:05interesting taste of that today with a 0:08little tweet from Gautam Kadia at 0:11Stripe. I want to go into it because I 0:13think it has profoundly disruptive 0:15implications for the industry. We're 0:18used to thinking of transformers as 0:20languagebased. The transformer reads all 0:23my books and it's a large language model 0:25transformer and it comes back with 0:26English or Croatian. Well, actually 0:28that's a bit of a joke because they 0:30don't speak Croatian in some cases 0:31because Croatians uh hit decline on so 0:35many of their responses. It's a little 0:37sidebar, but it is possible to get 0:39models to substantially change their 0:41trained behavior if enough users hit a 0:44negative feedback button. And in this 0:46case, you can look it up. There's an 0:48actual story where a model stopped 0:49speaking Croatia Croatian because 0:52Croatians didn't like the responses so 0:54much. But that being said, that's your 0:56humor for the day. Let's get back to 0:58Stripe. TLDDR. Stripe built a 1:02transformer-based learning model to 1:05detect fraud and it worked really really 1:06well. So for context, if you work in the 1:09payment 1:10space, machine learning is nothing new. 1:13Um, and machine learning models trained 1:15to detect fraud are nothing new. I used 1:17to work in payments myself. We use 1:19things like payment method, zip code, 1:21lots and lots of other features of the 1:24payment to improve the ability to detect 1:28fraud. And these are basically adding 1:31feature by feature by feature effects 1:33that basically work to maximize the odds 1:37that someone who's a legitimate 1:38purchaser can get through and obviously 1:40minimize fraudulent 1:41transactions. But at the end of the 1:44day, everything is driven around the 1:46future. Everything requires very 1:49specific training in classical machine 1:51learning to implement. And so each model 1:54has to think about authorization and 1:56fraud and disputes 1:58separately. And so the question that 2:00Stripe asked themselves was looking at 2:03how transformer architectures actually 2:05work. They're very generalized, right? 2:06They look across very wide swaths of 2:08data. Would an LLM approach work? And to 2:13be honest, it's I'm frankly I was 2:17skeptical. Like when I looked at this, I 2:19was like, "No way this actually worked." 2:22Because I didn't assume that payments 2:24were like language. Language has a 2:27grammar to it, right? Language has a 2:29sequence and it has rules. Well, what 2:33Stripe is discovering here is that 2:35payments do, too. Payments have some 2:38structural similarities to grammar. 2:42Now, there are things that that aren't 2:45the same. Uh there's many fewer tokens, 2:47for instance. Um the the principles that 2:50organize payments are not really like as 2:53rich as they are in linguistic 2:55grammar. Does it work? Apparently, yes. 2:59Uh so what Stripe did is they built a 3:01self-supervised network. It embeds 3:05vectors for every 3:07transaction. It's trained on at Stripe 3:10scale, right? So it's trained at the 3:11scale of tens of billions of 3:15transactions. Um, and it takes all of 3:17the key signals for a particular 3:19transaction and it distills it into a 3:21single 3:22embedding which means that you have a 3:26huge distribution of tens of billions of 3:28payments in vector space, right? 3:30Highdimensional vector space, which is a 3:32concept if you know large language 3:33models that you're very familiar with. 3:35And if you don't know large language 3:36models, I don't know, go read about it 3:38on the Substack. Uh, but the location of 3:42the embedding ends up capturing rich 3:44data the way the location of an 3:46embedding for a word captures rich data 3:47with LLMs. And that's what got my head 3:49spinning because it means that it's a 3:51generalized learning tool in a way that 3:53even I hadn't realized. And so 3:56basically, Stripe figured out that 3:58payments relate to each other in 4:00unexpected ways that transformers are 4:03able to articulate and understand better 4:07than classical machine learning 4:08techniques. and better than 4:11humans. And so payments that share 4:14similarities tend to nest next to each 4:16other in highdimensional vector 4:18space. And those that you know have even 4:23more similarities. Maybe they're from 4:24the same bank, maybe they're from the 4:26same email address, maybe they're from 4:27the same credit card number. Those nest 4:29even closer together. 4:31And what's fascinating about that is it 4:34lets you start to consider the 4:36relationships 4:38between payment structures in 4:40highdimensional space as potential fraud 4:43vectors. And so you can spot adversarial 4:47patterns and fraud techniques much more 4:49accurately. and previously like it's if 4:52you work in payments you know this 4:54there's an arms race that goes on that's 4:56silent every single day between 4:58fraudsters and legitimate payment 5:00providers where the payment providers 5:01are the front line of defense and 5:03fraudsters are trying to run fraudulent 5:05payments through the system and every 5:08day the fraudsters wake up and it's like 5:11uh wy coyote and the roadrunner 5:14everybody's trying to get a little bit 5:15faster and so this is a significant 5:18development in this arms race because it 5:19means that you can start to look at 5:21relational patterns and attack vectors 5:23that would not appear in traditional 5:26machine learning techniques that look at 5:27individual success 5:29uh goals or individual that optimize 5:32against individual transaction patterns. 5:35So for example, if you're optimizing 5:36around fraudulent patterns at login, 5:38you're not optimizing at the same time 5:40around fraudulent patterns at checkout 5:42or fraudulent patterns um with a 5:46particular 5:48uh presentation of payment method. So 5:50machine learning is sort of like a 5:52scalpel and LLMs which are machine 5:55learning but it's a different kind of 5:56learning architecture are much more 5:58generalized and they allow you to 5:59capture relationships between these 6:02patterns like what if someone has a 6:04certain pattern of login that then 6:06relates to a certain zip code that then 6:08relates to a certain payment method. 6:10Traditional machine learning techniques 6:11don't do a good job capturing that stuff 6:14and if you're at scale you can't 6:15necessarily pull that out individually 6:17by hand 6:18either. And so another example that 6:21Stripe actually gave was card testing. 6:23So with traditional machine learning 6:25approaches 6:26um you know where you engineer a new 6:28feature, you label attack patterns, you 6:30retrain models, you can reduce card 6:33testing a fair bit. You they said they 6:37reduce it at stripe by 80%. But the most 6:40sophisticated card testers still hide 6:42attack patterns in large company payment 6:45volumes and it makes it very very 6:47difficult to spot. But with a 6:51classifier that ingests the embeddings 6:55from the foundation model, you can 6:57predict if a particular traffic slice is 7:00going to be under attack. A particular 7:02traffic slice from a from a large 7:04company. which means you can leverage 7:06transformers to detect patterns in 7:08transaction sequences like their 7:11sentences and this can be done according 7:14to Stripe in real time so that you can 7:16block attacks before they hit 7:18businesses. 7:20So what they're saying is this 7:23particular model improved the detection 7:27rate for card testing attacks on large 7:30users from 59% to 97% 7:36overnight. Instant impact on Stripe's 7:39largest 7:41customers. And then they go on to say 7:44the real power of this is we can apply 7:45these same embeddings elsewhere. This is 7:47a foundation model. We're going to apply 7:48it to disputes. we're going to apply it 7:50to 7:51authorizations. Um, and then they call 7:54out the obvious to me, which is that 7:56payments have semantic meaning, like 7:58words in a sentence, right? If you make 8:01a payment, it has sequential 8:03dependencies and latent feature 8:05interactions that are not captured by 8:08manually listing features, which is 8:10exactly what transformers get at. 8:11Transformers get at hidden grammar, 8:13things that we don't know how to 8:14describe that describe English or 8:17describe another language. Transformers 8:19are very good at getting it. 8:21And 8:22so when I think about that and this is 8:24where I want to close. 8:27Fundamentally what Stripe has done is 8:29they have shown the way to disrupt a an 8:35industry that has used machine learning, 8:37that has used AI, that has lots of 8:38engineers, that is super bright, that is 8:40super focused on a particular problem 8:42and just completely upend it overnight 8:45by building a new foundation model based 8:47on transformers because they figured out 8:51that 8:52transformers are universal learning 8:54models. And so I want to ask the 8:56question, what other spaces are 8:59vulnerable to disruption if we thought 9:02about them as places where transformers 9:04could usefully 9:06learn? Do healthc care billing cycles 9:10have semantic meaning? I bet they 9:13do. Do treatment patterns and hospitals 9:16have semantic meaning? I know I'm 9:17zeroing in on on healthcare. That's 9:19where my head is at today, but that's 9:22that's just one example. Obviously, if 9:25Strike can do this part for fintech, you 9:27can see it on the stock side with Robin 9:29Hood relatively easily. What about 9:31education? Does a student's grade 9:34patterns through a particular school 9:36trajectory have semantic 9:38meaning? What about, I don't know, 9:42marketing? Do your leads, tracks, and or 9:46contacts through a particular pattern 9:48through the buyunnel? Does the buyunnel 9:51have semantic meaning? You see where I'm 9:53going here? Basically, ask yourself the 9:56question, what has semantic meaning in 9:59your world that you thought maybe is 10:02best mapped through traditional methods? 10:04Maybe it's not. Maybe it needs a 10:06transformer model and we just haven't 10:08built one yet. Which suggests that if 10:10there is a way to easily build new 10:14foundational models for these spaces, 10:17there's huge breakthroughs around the 10:19corner. So, think about it. What in your 10:21space is learnable by transformers that 10:24we haven't thought about