Skip to content
Case study 06 · FraudShield (MSc research)

A fraud detector that runs an LLM entirely on the phone.

My MSc research, published at RANLP 2025: fine-tuned, quantised LLMs under 1B parameters that flag fraudulent SMS and email offline, shipped as an iOS and Android app.

  • React Native
  • ONNX Runtime
  • PyTorch
  • Hugging Face
Role
Researcher and developer (MSc)
Team
Solo, supervised by Deshan Sumanathilaka
Timeline
May 2024 – May 2025
Stack
React Native, ONNX Runtime, PyTorch, Hugging Face
99.5%
accuracy
168 MB
model on device
0
cloud calls

The problem

Mobile payments keep growing, and so do scam texts and emails. Rule-based filters miss new wording. Large language models catch it, but they’re usually too heavy for a phone, and sending someone’s private messages to a cloud API to check them is its own privacy problem.

My research question: can a model small enough to download onto an ordinary phone detect financial fraud as well as a large one, fully offline?

What I built

  1. 1. Fine-tuning small models for one job

    I fine-tuned six compact chat models, from 32M to 1.1B parameters, to answer one question about a message: is it fraud?

    • QLoRA fine-tuning with PyTorch, Hugging Face Transformers, bitsandbytes and TRL, on a single GPU.
    • A cleaned, balanced dataset of fraud and legitimate messages.
    • Fair comparison against classic machine-learning baselines such as logistic regression, random forests, SVMs and XGBoost.
  2. 2. Shrunk and converted for phones

    I exported each fine-tuned model to ONNX with Hugging Face Optimum and quantised it to several sizes, from 16-bit down to 4-bit. They’re all published on Hugging Face, so the app can download whichever suits the phone.

    The best trade-off was Llama-160M at 4-bit: 99.47% accuracy in 168 MB. Smaller models loaded in under a second and answered in under half a second on a Samsung S21+ and an iPhone 14 Pro.

  3. 3. Running it offline in React Native

    • Expo with ONNX Runtime for React Native, running the model fully on the device.
    • transformers.js tokenizers, adapted to run in React Native.
    • Model downloads from the Hugging Face Hub, with pause, resume and progress.
    • A model list that can change without a new app release, so users can pick a model and size.

Where it went

The paper, Efficient Financial Fraud Detection on Mobile Devices Using Lightweight Large Language Models, was published at RANLP 2025, and FraudShield is live on the App Store and Google Play. It shows that a phone can run a useful LLM for a real security task, privately, and that a well-tuned small model can beat a general one on a narrow job.