Skip to content

Plate I · Selected work

Libra

Spanish banking transaction categorization

The scales — weighing and sorting into categories.

The service that sorts Spanish bank transactions into spending categories: clear rules first, one cautious AI call last, rebuilt end to end as sole engineer.

The result

97% right on 500 deliberately hard test transactions, about $0.10 spent on AI per 1,000 transactions, and the AI’s own answer in 0.3 s at the median. Measured June to October 2026.

Role
ML Engineer
sole owner of the AI service
Timeline
Since March 2026
SPRK Software & Tech
Stack
  • Python 3.14
  • FastAPI
  • PostgreSQL
  • Redis
  • AWS ECS · CDK
  • Amazon Bedrock
  • Qwen3-32B
  • Cohere embeddings
On this plate ProblemApproachResult
  1. 01 Problem
  2. 02 Approach
  3. 03 Result

Follow one transaction

A shop it knows

What the bank sends MERCadOnA s.a. #2b1cC30 /BcN −198,04 €
  1. Has this person corrected one like it? Nothing
  2. Does its shape give it away? (a Bizum, a payroll, a cash withdrawal) Nothing
  3. A rule learned from everyone’s corrections? Nothing
  4. Is it a shop we know? Mercadona → Supermarket · 98% sure
  5. Does the card network’s shop code say? Skipped
  6. Is it a known subscription? Skipped
  7. Do its words say? (the tax office, a fee, interest) Skipped
  8. Like a transaction seen before? Skipped
  9. Ask an AI model, once (it may say it doesn’t know) Skipped
  10. A person reviews it Skipped

Result Supermarket Settled by a rule. No AI needed.

A tax payment

What the bank sends AEAT IVA IDA64Y5EB −666,64 €
  1. Has this person corrected one like it? Nothing
  2. Does its shape give it away? (a Bizum, a payroll, a cash withdrawal) Nothing
  3. A rule learned from everyone’s corrections? Nothing
  4. Is it a shop we know? Nothing
  5. Does the card network’s shop code say? Nothing
  6. Is it a known subscription? Nothing
  7. Do its words say? (the tax office, a fee, interest) Names the tax office: Tax · 83%, under the 85% a rule needs
  8. Like a transaction seen before? Nothing
  9. Ask an AI model, once (it may say it doesn’t know) Tax · 92% sure, over the 90% the model needs
  10. A person reviews it Skipped

Result Tax The rules had a hunch; the model confirmed it.

A shop no one knows

What the bank sends SH31N ID5780 /MAD −312,42 €
  1. Has this person corrected one like it? Nothing
  2. Does its shape give it away? (a Bizum, a payroll, a cash withdrawal) Nothing
  3. A rule learned from everyone’s corrections? Nothing
  4. Is it a shop we know? Nothing
  5. Does the card network’s shop code say? Nothing
  6. Is it a known subscription? Nothing
  7. Do its words say? (the tax office, a fee, interest) Nothing
  8. Like a transaction seen before? Nothing
  9. Ask an AI model, once (it may say it doesn’t know) “I don’t recognise this shop.”
  10. A person reviews it Sent for review instead of guessed

Result Needs review Honest about what it doesn’t know.

Three test transactions, run through the real service on 30 October 2026. Rules answer first; an AI model is asked at most once, and is allowed to say it doesn’t know.

Problem

SPRK makes a personal-finance app for Spain. It reads people’s bank transactions through Open Banking, and almost everything it offers (where the money goes, which subscriptions renew, what fixed costs are coming) depends on one quiet job: putting each transaction in the right category.

  • MERCadOnA s.a. #2b1cC30 /BcN −198,04 € Supermarket by a shop it knows
  • sQ *ENDeSA sa /e65ce9Z −109,27 € Home by a shop it knows
  • ubER *B63a1d3 −170,22 € Transport by a shop it knows
  • NomINA EMPrEsa s.L. +2.189,88 € Salary by its words
  • retIRadA CAjeRo llc IdE9bEa −132,53 € Cash by its words
  • BIZUM de Ana Fernandez +1.066,57 € Bizum by its shape
  • REfund - aMAZON +185,60 € Refund by its shape
Real test rows, messy as banks send them, sorted by the real service

Banks don’t make it easy. Each line is a short, mangled piece of text, and the codes that should say “card payment” or “transfer” turned out to be almost the same for every transaction from a given bank. So the service trusts only what it can check, such as whether money came in or went out, and treats “unknown” as an answer, never an error.

Most spending goes to shops everyone knows. But about half of all transactions name small local businesses that no general AI model has ever heard of: the long tail.

Money in 5

  • Salary
  • Extra income
  • Refund
  • Gift
  • Loan

Money out 21

  • Supermarket
  • Restaurant
  • Subscriptions
  • Transport
  • Vehicle
  • Shops
  • Health
  • Pharmacy
  • Sports
  • Leisure
  • Clothing
  • Accommodation
  • Travel
  • Personal care
  • Home
  • Insurance
  • Education
  • Debt
  • Fees
  • Tax
  • Pets

Either way 5

  • Bizum
  • Transfer
  • Investments
  • Cash
  • Other
31 categories. Whether money came in or went out decides which ones are possible

The goal was explicit: settle as many transactions automatically as possible, while spending as little as possible on AI. I joined as the only engineer on the AI service. The prototype I inherited chained twelve decision layers in a single 830-line file; none of it survived unrewritten.

Approach

  1. Rules

    Instant, free, explainable. An answer must be at least 85% sure.

    1. Has this person corrected one like it?
    2. Does its shape give it away?
    3. A rule learned from everyone’s corrections?
    4. Is it a shop we know?
    5. Does the card network’s shop code say?
    6. Is it a known subscription?
    7. Do its words say?
  2. Memory

    Is it like a transaction seen before?

  3. One AI question

    With what is already known about the shop. It must be 90% sure, and may answer “I don’t know”.

  4. A person

    Nothing was sure enough: it goes to review, with a suggestion.

Ten questions in four bands. Each band is only asked if the one before was not sure

Rules first. They are instant, free and explainable, and they live as data anyone on the team can read: 458 known shops, 40 shop profiles, 36 kinds of bank wording and 97 card-network codes. They are checked every time the service starts, so a broken entry stops a release instead of mislabelling someone’s payment.

One AI question, allowed to say “I don’t know”. When no rule is sure enough, the service asks a model once, telling it what is already known about the shop. If the model is unsure or unreachable, the transaction goes to a person instead of waiting or guessing. Every call is cached, its cost recorded, and switched off automatically when a provider fails.

Two decisions I reversed

Before

Three AI models vote, and an arbiter picks the winner.

After

One model, given what is known, allowed to say “I don’t know”.

Voting only helps when the voters make different mistakes. On small local shops they all share the same blind spot, so agreement proved nothing.

Before

A learning model in the live path, needing ~100,000 labelled examples. There were ~7,500.

After

Trained offline, to switch on when there is enough data.

The arithmetic said it could not work yet, so it waits instead of guessing live.

Each reversal argued in a written proposal before a line changed

How it learns from corrections

  1. You fix a categoryThe correction is saved on the transaction itself
  2. Twice the same fixIt becomes a rule for you, asked before anything else
  3. For everyoneRules learned from corrections are proposed for all users, and a person approves them
  4. Spot checks2 in every 100 automatic answers are re-checked
Every correction makes the next answer better, but never without review
AWS · private network SPRK’s app

asks for a category

Front door

load balancer · firewall · allow-list

The service

containers · ECS Fargate · two zones

Alarms

16 watches · CloudWatch

Keys & secrets

Secrets Manager · KMS

Canary

tests it every 5 minutes

Database

PostgreSQL · each person’s rows walled off

Cache

Redis

AI models

Amazon Bedrock, over a private link · Qwen3-32B · Cohere embeddings

Files

S3 · models · replay recordings

How it ships GitHub Actions → container registry (ECR) → database migrations → AWS CDK: every part defined in code
How it is deployed on AWS. Every box is defined in code, reviewed like code

Built as a product, not a prototype. The service and the platform under it, a full AWS deployment defined in code, are mine end to end (on 29 October 2026, 1,860 of the repository’s 1,902 commits and all 52 of its written design proposals). Privacy shaped the design: personal data is encrypted, logs never contain names, each person’s data is walled off from everyone else’s, and a request to delete stops all processing at once.

Result

97%
right on 500 deliberately hard test transactions
30 Oct 2026
$0.10
spent on AI per 1,000 transactions, every model call included
Jun–Sep 2026, 10,480 transactions
0.3 s
for the AI’s answer at the median, 0.9 s for the slowest 5%
Aug 2026 benchmark
3 in 5
transactions settled by clear rules, before any AI is asked
20 Aug 2026, 7,584 judged
0
failures in 1,624 live AI calls over 62 minutes
20 Aug 2026
Measured, not estimated: each figure with the date it was taken

Where 7,584 judged transactions were settled · 20 Aug 2026

  • A shop it knows 2,380 · 31.4% matched the judgment 82%
  • The transaction’s shape 1,493 · 19.7% matched the judgment 76%
  • Bank wording for transfers 391 · 5.2% matched the judgment 80%
  • Words in the description 358 · 4.7% matched the judgment 73%
  • The AI model 6 · 0.1% matched the judgment 100%
  • Sent to a person 2,865 · 37.8% the long tail
Three in five settled by rules. Nearly two in five went to a person, most for shops it had not been taught yet

Asked about shops it had never heard of · 20 Aug 2026 recording

“I don’t know”: 1,611 an answer: 13
The model said “I don’t know” 99 times in 100 instead of guessing

The result I value most is the measurement, because it produced the most useful and least flattering number of the project. In July, on a small, hand-picked set, the service looked 93% right. On 20 August, on all 7,584 judged transactions, it was 52%. Not a regression: the long tail. On the small set, 3.6% of transactions went to a person; on the full set, 37.8%.

That number pointed the work in the right direction. Three quarters of the manual reviews came from missing knowledge about shops, not from the model or from how sure it was. The model of the time agreed: allowed to say “I don’t know”, it did, 99 times in 100, and giving it more detail about each transaction changed nothing. The bottleneck is knowledge, not the model.

Every change is now tested against reality, for free. 1,624 model answers recorded on 20 August (62 minutes of live calls, without a single failure) replay exactly from the recording, at no cost. The first replay failed loudly, with 73 answers missing, and was reconciled before anyone trusted it. One change to how a winner is picked was shown to move just 9 of 7,584 answers, and shipped behind a switch that can be turned back without a release.

In August, where the model ran mattered as much as which model it was. The same open model scored 48% on one host that ignored the required answer format and 60% on one that enforced it; moving made a whole class of failures (16% of answers cut off mid-way) impossible.

On 30 October 2026, on 500 deliberately hard test transactions, the service got 97% right with its current model, Qwen3-32B on Amazon Bedrock, whose own answer takes 0.3 s at the median and 0.9 s for the slowest 5% (benchmark, August 2026).