Real time fraud detection on phone calls

You can spot a scam call, right? I mean, we are all smart people. Well, yes and no in terms of falling for scam calls. I will be the first to admit falling for a couple of scam calls in my early days. Once you start to learn the patterns the scammers use, it is not so easy to be fooled anymore. Well, what about your mom, dad or grandparents? Are they up to date with the latest scam tactics? Not even mentioning the technology behind all of it. When can you give out your OTP (never!), when can you confirm your ID number? When is it safe to give any information out? “But the person on the other line was so friendly and said he worked for the bank!”

I’ve decided to build a proof of concept AI model that might help with alerting you when you might be talking to a scammer or not. Imagine being told in real time if the conversation you are having might be fraudulent or a legitimate call. Yes, I know there are other methods being implemented, like some banking apps warning you that the call you are on is not from the bank while having your banking app open. But what if you never open your banking app and just confirm an OTP sent via SMS?

This proof of concept AI model can listen to your conversations and rate the likelihood of it being a fraud call in real time. From there, you can decide to end the call or perhaps have the application end the call and even block the number automatically.

But don’t just take my word for it. Below is a recording of me talking in real time while the AI model decides if the conversation is linked to fraud or not.

 

 

Well, this is nice and all, but what about a real phone call? Well, since I built this whole proof of concept over a weekend, I did not have time to get hold of actual fraud calls and test it against my AI. So I created two AI personalities to play the parts. Both of these voices you will hear are fully AI-generated and not real. I played the generated conversation through my computer’s speakers and then had my computer’s microphone listen to it in real time. Yes, I know there are easier ways, but I wanted a realistic scenario. And with this setup, I could also have joined the conversation at any time if I wanted.

I created four scenarios. Two that will trigger the fraud alert and two that are legitimate conversations that will not trigger a fraud alert. In one of the videos, you will see the “fraud meter” rise and fall as the AI model takes the whole conversation into account every second and not just the last couple of words. So you could have been talking about something that might sound suspicious; however, later in the conversation, it will be clear that it was, in fact, not.

Sample Fraudulent Calls

 

 

 

Sample Legitimate Calls

Well, how did I create this, you may ask? Well, in short, there are two main components to this. Both AI models. The one is used to transcribe voice into text in real time, and the other is to decide if the conversation so far is fraudulent or not and give a percentage of the likelihood.

The speech-to-text model was the easiest to implement as I only had to tweak a couple of parameters to get the model running in real time on my semi-outdated GPU. The model that decides if a call is fraudulent or not was the tricky part, and I will come back later to getting them to play nicely and share one GPU.

So the model that decides if a conversation is fraudulent or not is based on a new type of AI model called a decision model. For those in the field, it’s a JEV-type model. This model cannot help you with coding or summarize your email for you. This type of model is really REALLY good at making decisions based on input. You give it a set of answers it can choose from and some input, and it will give you the most likely answer back in a couple of milliseconds. Yes, not seconds, milliseconds! Thus, it’s able to run in real time!

Wow, that was easy. Anyone can do this, just point Claude or GPT to the task and say go, right? Well, yes, but also no. Any JEV-type models are trained on a lot of things, and if they do not know, they will also, like all AI models these days, guess. And their guess might not always be very good. So yes, it can make a decision very quickly, but that decision might not always be the right one.

So how do you fix it? Well, you fine-tune it. Basically, send it to college to become an expert in a specific field. Where in the past it was rather good at most things, it will then become an expert in a specific subject. This is called fine-tuning if you want to use some AI words at your next water cooler get-together. Ok, fine, but how? How do you take a model and teach it if a conversation is fraud or not? Well, the same way you would teach a human, in a way. By showing it a bunch of conversations containing fraud and not containing fraud. Nice, but where do you get the “textbook”? Well, that was the fun part, you don’t. There are datasets containing fraudulent conversations; however, they are not based on South Africa. Some are from the US and will refer to the IRS instead of SARS and not even know what an OTP might be. So I had to create my own “textbook” from scratch.

Long story short, I had my AI minions do deep research into all the types of phone fraud being committed in South Africa at the moment. How each is done, the types of questions asked, the level of interaction the fraudsters require from the victim and so on. Once I had all this compiled, I had my AIs generate about 10 000 conversations based on the deep research data. I had one smart AI supervise one less smart AI running locally. Else my token budget would have gone through the roof.

Below is a small example of the training data. You can see this covers a large range of scenarios, both fraud and non-fraud related, but all based on how South Africans would interact.

{"state": "Gogo? It's Tumelo, can you hear me, the signal is bad here.\nJa my child, I hear you. Where are you now?\nI'm at the bus station in Joburg, the bus to Polokwane leaves at six.\nOkay, good. Are you bringing the Christmas things? The blankets?\nYes, I've got them in the big bag, and the shoes for Thabo.", "questions": {"fraud": {"type": "noul", "instructions": "Is the caller in this phone conversation attempting fraud or a scam?"}}, "expected": {"fraud": false}, "call_id": "00011", "category": "clear_normal"}
{"state": "Hi, it's Themba from Themba's Motors, your car is ready for collection.\nJa, great, what did you fix in the end?", "questions": {"fraud": {"type": "noul", "instructions": "Is the caller in this phone conversation attempting fraud or a scam?"}}, "expected": {"fraud": false}, "call_id": "00029", "category": "clear_normal"}
{"state": "Hi Mrs Patel, it's Joyce, I can't come on Tuesday.\nOh no Joyce, what happened? Are you sick?\nNo, my son has a meeting with the principal at his school. I'll come on Wednesday instead.\nOkay, Wednesday is fine, is it the same time, eight?\nJa, eight, I'll do the bathrooms and the kitchen. The lounge is done already.", "questions": {"fraud": {"type": "noul", "instructions": "Is the caller in this phone conversation attempting fraud or a scam?"}}, "expected": {"fraud": false}, "call_id": "00050", "category": "clear_normal"}
{"state": "Good afternoon, this is Home Affairs, your passport application is ready for collection.\nReally? I thought it was going to take longer. Which office?\nThe one in Mthatha, or you can choose the branch on the website, it's the same place.\nOkay, do I bring the old ID, or just the receipt?\nBring your ID book, and the collection slip we sent you, that's all.\nAlright, I'll go next week, what are the opening times?", "questions": {"fraud": {"type": "noul", "instructions": "Is the caller in this phone conversation attempting fraud or a scam?"}}, "expected": {"fraud": false}, "call_id": "00126", "category": "tricky_normal"}
{"state": "Hello, this is Sea View Lodge in Hermanus, confirming your booking for the weekend.\nJa, the double room with the sea view, for two nights?\nYes, Friday to Sunday, the room is on the top floor, and breakfast is included.\nThat's nice, what time is check in?", "questions": {"fraud": {"type": "noul", "instructions": "Is the caller in this phone conversation attempting fraud or a scam?"}}, "expected": {"fraud": false}, "call_id": "00295", "category": "subtle_fraud"}

 

I also did not just want calls that were 100% fraud and 100% not fraud. That would have been too easy. What if the calls were just hinting at fraud and the fraudsters were being very smooth without saying what they wanted outright? So I also decided to add a lot of conversations that were subtly linked to fraud without outright saying obvious things like “send me your OTP PIN”.

Below are some data and graphs showing how well the model did before and after fine-tuning. The base model got about 36% correct in predicting fraudulent calls, while the fine-tuned model got about 94% correct. I did not want to overfit the model on the training data, so I only ran the fine-tuning through four passes. I kept a lot of the training data out to test the model afterwards to make sure it did not just learn the answers without understanding them. So, in total, the model was trained on about 7000 conversations, leaving the rest to test the final model on, and the stats you see below are the results of that.

 

 

So can this only be used for fraud detection? No, not at all. You can fine-tune the model to predict if the caller on the line is happy or angry based on sentiment analysis. Perhaps use it to track how helpful call center staff are when assisting clients. Or even something as simple as detecting what department a client wants to be connected to based on their described problem.

If you wish to use my code and the custom AI model I created, feel free to use the GitHub link below:

 


On a more serious note, if you or your company might be interested in incorporating this workflow please contact me at jacomoolman1890@gmail.com