Turning UAE bank SMS into categorised spending, and answering questions about it in plain English
meet Fils 🪙
Danish Ali · 5584978 · UOWD Master of Applied AIDr. Pallavi Ranjan · Week 6
Hi everyone. This is my NLP solution design: it reads the bank SMS we all get after every card payment, figures out what each payment was for, and then lets you ask questions like "how much did I spend on food in May?". This is Fils, the project owl, named after the fils, the smallest UAE coin.
Audience game
Guess the category
Four real merchant names, exactly as the bank SMS wrote them.
Quick game. These are four merchant names exactly as they arrived in SMS. Shout out a category for each. Karak House, easy. Etisalat QuickPay, easy. McDonald's-ADNOC, medium. And New Salah Aldin, hard. Have a guess.
The reveal
Easy for you, hard for a model
KARAK HOUSE JLT
Food & dining
"KARAK" is a telling word
ETISALAT QUICKPAY
Utilities & telecom
a brand the rules know
MCDONALDS-ADNOC 74-541
Food & dining
a restaurant inside a petrol station
NEW SALAH ALDIN-1076
Health (Life Pharmacy!)
legal name ≠ brand name
no model can guess this one 🤷
Labels confirmed by the cardholder3 / 16
Answers: Karak House is food, the word karak gives it away. Etisalat is telecom, a known brand. McDonald's-ADNOC is food, it's a McDonald's inside a petrol station, and my own pipeline got this wrong at first. New Salah Aldin is a Life Pharmacy branch trading under its legal name. Nothing in the text says pharmacy, so no model can know. That's why the design includes asking the user.
The problem
We all get the data. Nobody can use it.
Your Cr.Card XXX2847 was used for AED25.73 on 24/07/2022 at NEW SALAH ALDIN-1076,DUBAI-AE. Avl. Cr.limit is AED…
To answer "how much did I spend on health this month?" a system must:
tell a purchase from an OTP or refund
pull out amount, date and merchant from 5 different bank templates
know what the merchant is
add it up correctly
Open Finance is still rolling out bank by bank. SMS are already on everyone's phone, with no login and no consent hoops.
Problem definition4 / 16
Every UAE bank sends an SMS for every card payment, so the data already exists on our phones. But it's unusable as is: each bank has its own template, merchant names are truncated or legal names, and nothing says what the purchase was for. Open Finance would help, but it's still being rolled out, so SMS is the realistic source today.
The data
Real SMS only. No synthetic data.
19,641
bank SMS
11,368
usable expenses
6
banks · 5 people + 1 public set
1,930
distinct merchants
Training & testing: my own ADCB and Liv SMS, plus four volunteers (FAB, Mashreq, Liv, Liv), 2022–2025.
External test only: Khalifa University's public Kaggle set (ADIB, 7 anonymous users). Never trained on.
names & card numbers masked 🔒
Cut-off 31 Dec 2025 · censored before analysis5 / 16
About twenty thousand real SMS from six banks. Five people contributed, including me, and a public dataset from Khalifa University is kept aside purely as an outside test from a bank the model never sees. Before anything else, names, IBANs, card numbers, OTPs and reference numbers were masked, and a privacy test checks it.
Labels were pre-filled by rules and AI-assisted research, so I re-labelled a random sample without looking at them. 8 of the 9 disagreements were conventions (beauty shops → retail), which I then applied everywhere.
I chose 12 categories that match how people here think about money, including Government Fees for visas, Emirates ID and fines. Labelling is per merchant. Because a lot of the first-pass labels came from rules and AI-assisted research, I ran a blind audit: I labelled 150 random merchants myself without seeing the existing labels. We agreed 94 percent of the time, kappa 0.93.
The design
Two stages
Stage 1 categorise · Stage 2 answer7 / 16
Stage one: parse each SMS with bank-specific rules, clean it, and categorise it through a cascade. Stage two: a local LLM turns your question into one SQL query, a guard checks it is read-only, and the database answers. The LLM never does the maths.
Every tier gives a score for all 12 categories. If none is confident enough, the best guess is still saved but marked needs_review. Your answer goes back into the lookup, so you're never asked twice.
Threshold chosen from data8 / 16
Each expense goes down the tiers until one is confident. Known merchants are a lookup. Then brand and keyword rules. Then the calibrated model. Tier four, a model with brand knowledge, is the next step. If nobody is sure, it still files a best guess but asks you, and remembers your answer.
Results · macro-F1
The honest number is the low one
Random 5-fold
94.9%
Future (2025)
89.2%
Unseen person
80.3%
Another bank (ADIB)
59.4%
Brand-new merchants
51.2%
Exact lookup scores 4.1% on brand-new merchants, so the model does generalise, just not enough on its own.
This is the key result. With a normal random split the model scores 95 percent, but that's because the same merchants appear in training and testing. Test on later months, new people or another bank and it drops. Test on merchants it has never seen and it's about 51 percent. Most published work reports the top bar. The bottom bar is what happens with the first purchase at a new cafe.
Error analysis
The McDonald's-at-ADNOC bug
The model kept calling some "transport" purchases food. The model was right.
My cleaning step matched fuel brands before restaurants, so MCDONALDS-ADNOC became "ADNOC". 132 purchases were mislabelled.
After fixing the labels
53.3 → 51.2
new-merchant macro-F1 went down
"ENOC" now also appears in food examples, and ENOC alone is 6.6% of all purchases.
clean labels > pretty scores
Found through error analysis, not by luck10 / 16
My favourite finding. The biggest error group was transport predicted as food, on names like McDonald's-ADNOC. The labels were wrong, not the model: my brand table checked fuel stations before restaurants. Fixing 132 labels made the score go down, from 53 to 51, because the word ENOC now appears in food examples too. I report the lower, honest number.
Knowing when it doesn't know
Calibrated confidence
A score of 0.7–0.8 on a brand-new merchant was right 95% of the time.
Review threshold 0.60
31% of brand-new-merchant purchases filed automatically at 91% accuracy. The rest go to tier 4 or to you.
Platt calibration on merchant-grouped folds11 / 16
Raw model scores are over-confident on new merchants, so I calibrated them on merchants the model hadn't seen. Now the confidence means something where it matters: 0.7 to 0.8 was right 95 percent of the time. At a threshold of 0.6, about a third of brand-new merchants get filed automatically at 91 percent accuracy, and the rest are asked about.
Stage 2
Ask your spending anything
"How much did I spend on food and dining in May 2025?"
Local LLM (Qwen2.5-1.5B-Instruct) writes:
SELECT ROUND(SUM(amount_aed),2) FROM expenses WHERE user='U12' AND category='Food_Dining' AND month='2025-05'
692.20
AED, straight from the database
only one read-only SELECT allowed
DROP / UPDATE / PRAGMA blocked
the LLM never types a number
runs locally, so SMS never leave
Text-to-SQL with guard rails · live demo at ledger.danishali.dev/dashboard12 / 16
Stage two. You ask a question, a small local LLM writes one SQL query, a guard checks it's a single read-only select, and SQLite answers. The number you see comes from the database, never from the LLM, and the SQL is shown so you can check it. Everything runs locally. On the dashboard you can run the same guarded SQL against any card-holder.
Why categorisation matters
Small errors, wrong answers
Questions without categories
100%
"How much at Amazon?"
Category questions · known merchants
55%
median error 5%
Category questions · new merchants
5%
median error 89%
30 gold questions, answered on true vs predicted categories. A 97.7%-accurate categoriser still got almost half the category answers wrong, because one big misfiled purchase (a 6,000 AED item) swings a whole year.
this is why we ask 🙋
Answer correct = within 1% of the true-category answer13 / 16
This links categorisation to what the user actually sees. I wrote 30 questions with gold SQL and answered them on true and predicted categories. Questions that don't involve categories are always right. Category questions are right 55 percent of the time even with a 97.7 percent accurate categoriser, because a single big misfiled purchase moves a total. With brand-new merchants only one in twenty is right. So the review step should focus on the purchases that matter most.
Responsible by design
Your money, your phone, your call
Privacy
Masked before analysis; local LLM; code-only repo. UAE PDPL.
Consent
Contributors asked; data shared only on request; public set cited.
Bias check: accuracy ranges 75–86% macro-F1 across people. Spending style matters, so results are reported per person and per bank.
Ethics and mitigations14 / 16
Ethics shaped the design. Privacy by architecture: everything can run on the device. Consent from every contributor before sharing. No invented numbers, because the LLM only writes SQL. And against over-trust, the system shows its confidence and asks when unsure. Accuracy also varies by person, so I report per person and per bank.
Assistant results · what's next
Teach it brands, and better SQL
Text-to-SQL · Qwen2.5-1.5B
67%
correct on 30 gold questions (75% category, 50% control). Guard rejected none; mistakes were mostly bank vs merchant mix-ups.
Advice answers
Numbers real, maths not
"Save 1,000 AED" → three cuts adding to 295. Next: fixed analysis tools compute every figure, the LLM only ranks and phrases.
Tier 4 · Week 11
DistilBERT / XLM-R vs embeddings vs LLM
Same five honest tests, target the 51% on new merchants; plus a SQL-specialised model and Arabic SMS.
Group project (Week 11) builds on this15 / 16
The assistant results. The 1.5 billion parameter Qwen model wrote correct SQL for 20 of 30 questions: 75 percent of category questions and 50 percent of controls. The guard never had to reject anything; the mistakes were schema confusions, mostly filtering the bank column instead of the merchant. The advice answers were the weak spot: asked how to save 1,000 dirhams, it suggested cuts that add up to 295. So next, advice goes through fixed analysis tools that compute every number, and tier four adds brand knowledge, tested on the same five set-ups.
Ledger · MAAI902
Thank you
Every purchase gets a category, a confidence score, and an answer you can trace back to the SMS.
ledger.danishali.dev
Questions?
Danish Ali · 5584978 · MAAI90216 / 16
That's it. Thank you, I'm happy to take questions. The site and the dashboard are at ledger.danishali.dev.