Inspiration

The Africa Deep Tech Challenge targets "the 8 GB laptop on desks in classrooms, clinics and corner shops." The person actually typing at that laptop, in our case, is a shop owner or a bookkeeper running an informal-sector business in Lagos or Kano. Cloud accounting software never reached them: it bills monthly in scarce forex, assumes internet they don't have, and doesn't understand how their business actually runs on mobile money, in naira, under Nigerian tax rules.

Then we found the sharper problem. Nigeria rewrote its tax law in 2025, the Nigeria Tax Act and the Nigeria Tax Administration Act, effective January 2026. That is after the training cutoff of every mainstream model. Ask a stock LLM what VAT is in Nigeria and it confidently quotes the repealed 5%. Ask about the small-company threshold and it gives you the old ₦25 million instead of ₦100 million.

For a shopkeeper deciding what to charge a customer or what to file with FIRS, confidently wrong is worse than nothing. That gap, a brand-new law that no available model knows, is what this project exists to close.

What it does

An offline financial intelligence engine for Nigerian SMEs. Not a chatbot: two halves that need each other.

  • A fine-tuned 3B model (1.93 GB, ~2.0 GB RAM) that understands a messy request in plain English and knows the 2025 tax facts.
  • A deterministic finance engine (stdlib-only Python, 113 tests) that computes every number.

The model narrates; the engine computes. The engine's output is injected into the model's prompt as ground truth it must restate exactly, so a figure a business acts on is never a guess.

Upload your books, a real Excel or CSV export, straight from your spreadsheet or bank and ask:

  • "What happened to my business this month?" → 371 transactions become a health report: revenue, margin, cash position, receivables aging, and which expenses actually moved.
  • "Is anything unusual?" → a robust statistical scan (median/MAD, so one freak month can't hide the rest) narrows hundreds of transactions to a short list: a supplier paid twice, a unit price that jumped 80%.
  • "Will I have enough cash next month?" → a projection from the business's own trading history, with a range rather than false precision, measured against known obligations.
  • "How much cash is tied up in stock?" → inventory at weighted-average cost, true COGS, turnover, and the cash-conversion cycle — including capital frozen in goods that haven't sold in 90 days.
  • "What should I do?" → ranked, quantified actions ("chase Adeyemi Construction — ₦684,000, 24 days overdue"), and an honest statement of whether they close the gap.

Plus reconciliation ("this ₦127,500 MoMo payment clears both invoices"), Nigerian tax answers with citations to the Act, and VAT-correct quotes.

Everything runs on the laptop. No internet, no API key, no data leaving the building.

How we built it

Everything: data generation, fine-tuning, quantization, evaluation ran on one 8 GB M2 MacBook. Constraint-native, end to end.

1. A verified fact base. We OCR'd the official Federal Republic of Nigeria Gazette (210 pages) plus the Tax Administration Act, and hand-curated 38 facts, each tagged primary_confirmed (found verbatim in the Act) or secondary_corroborated (agreed by two or more of EY, KPMG, Baker Tilly, Aluko & Oyebode). The data generator is forbidden from stating any number not in that file.

2. 5,216 training examples across five generators, three fully deterministic, so a wrong answer cannot enter the corpus. Arithmetic is computed by code, never generated by a model. The newest 1,100 examples use our own finance engine as the oracle: the engine computes the verdict, the example is built around it.

3. True QLoRA on a pre-quantized 4-bit base (rank 32, all 36 layers, 1.94% trainable), the only way a full-quality fine-tune fits in 8 GB of unified memory.

4. imatrix Q4_K_M quantization, with the importance matrix calibrated on our own domain corpus and computed on a Q8_0 copy on the GPU, 4 minutes instead of 2.5 hours on CPU, and it recovers most of the accuracy 4-bit would otherwise cost.

5. Three evaluation gates, fixed before results were seen: 37 adversarially-phrased Nigeria fact questions, 12 arithmetic cases, and 5 narration-fidelity checks that verify the model never invents a figure. Nothing ships unless it clears them.

Challenges we ran into

The Mac kernel-panicked mid-training. Not a crash, a full system panic, traced to an open Apple bug in the GPU driver (FB22091885) triggered by sustained Metal load. We fixed it by capping Metal memory, cache and wired limits before training starts; peak dropped from 4.18 GB to 3.71 GB and it never recurred.

The audit build is deliberately SIMD-disabled. We fetched the official profiler's Dockerfile and confirmed every vector path is switched off, so generation is scalar, roughly 8–10× slower than the same chip with AVX2. We measured 2.75 tok/s on audit-class x86 hardware and designed around it rather than chasing it, since speed is scored relative to the field and every submission runs the same de-optimized binary.

A wrong diagnosis that cost a full retrain. When fact accuracy collapsed from 34/37 to 26/37, we confidently blamed "gradient dilution" and spent an hour retraining on that theory. It was wrong. Adding new scenario families had silently moved three fact-drill families wholesale into the holdout set, so those facts had zero training data. A dilution effect degrades broadly; ours was surgical - three topics, six of the eight lost questions. The disproof was visible in our own topic breakdown before the wasted run.

Our own eval was contaminated. A check found three eval questions appearing verbatim in the training corpus, the generator had independently produced the same obvious phrasing ("What is the current VAT rate in Nigeria?"). Those questions were measuring memorisation, not recall. We rephrased them and added a guard that fails the build if it ever happens again.

A licence we caught late. Qwen2.5-3B ships under qwen-research (non-commercial), not Apache-2.0 as our model card had claimed. We corrected the card, added the required attribution, wrote a dual-licence LICENSE (MIT for our code, Qwen's terms for the weights), and disclosed it plainly in the report rather than leaving it implicit.

Accomplishments that we're proud of

The model knows a law that no other model knows. VAT 7.5% ✓ · small company 0% CIT ✓ · standard 30% ✓ · Development Levy 4% with small companies exempt ✓ and the nuance most models miss: a consulting firm under ₦100M still pays 30%, because professional services are excluded from small-company status. Fact recall went from 24/37 to 34/37.

Every figure is computed, never guessed. We measured where a 3B model fails at money arithmetic, then built the deterministic engine precisely there. Its test suite is literally our model's measured failure list — partial-payment carry, applied thresholds, multi-invoice allocation. That is what makes this safe to point at someone's real books.

Hausa and Igbo, done properly. The interface speaks both but deliberately not by asking the model to generate them. Because every figure is computed, rendering it in another language is a formatting problem, not a generation problem, so a wrong number is structurally impossible. Native reviewers corrected 11 of 14 Hausa strings and 10 of 14 Igbo strings, and the Igbo financial vocabulary is cross-checked against a published bilingual banking glossary (IGBOSCHOLARS Journal, 2013). Working separately, both reviewers made the same correction our draft had conflated net profit with remaining balance in both languages. These are two of Nigeria's three major languages, spoken by the people actually running these shops.

It fits the hardware it was built for. 1.93 GB on disk, ~2.0 GB peak RAM against a 7 GB budget, trained and quantized entirely on the same class of machine it runs on.

What we learned

Validation loss does not track what is scored. This is the lesson of the whole project. Across four retrain attempts, every candidate was blocked by our evaluation gates and every one of them looked fine by validation loss. One had the best loss curve of any run while its facts were eight questions worse. Without gates fixed in advance, we would have shipped it and never known.

Check the data before re-running the model. The retrain we wasted on a wrong theory would have been avoided by a two-minute inspection of how the train/holdout split had shifted. Now any fact regression is diagnosed in that order: is the data present, is the eval intact, and only then the model.

Specificity beats breadth. We deliberately built for one market properly rather than a shallow pan-African tool. Mobile-money reconciliation and the Nigeria Tax Reform Acts 2025 are things only this user needs, and getting them right required the OCR'd Gazette rather than a summary. A generic "African business assistant" could be anywhere; this could not.

Small models are better teammates than soloists. A 3B model is excellent at understanding a shopkeeper's messy question and explaining an answer in plain language. It is not reliable at carrying a remainder across three invoices. Building the system around that division — instead of hoping the model improves is what made it trustworthy.

What's next

Hausa and Igbo input, not just output. The interface already answers in both; the next step is understanding a question typed in them.

PDF bank statements. Nigerian bank statements arrive as PDF, and layouts vary enough that a careless parser would invent figures, so we refuse them today rather than guess. Doing it properly, per-bank, is the highest-value ingestion work left.

Pilot deployments with real shops, where the measure that matters is whether an operator's books close correctly at month end.

Migration to a permissively licensed base for commercial deployment. Because the engine, the data generators and all three evaluation harnesses are MIT and base-model-agnostic, this is a contained change - retrain, re-run the gates, rebuild and the configuration is already in the repository.

Built With

  • apple-silicon
  • docker
  • edge-ai
  • fine-tuning
  • fintech
  • gguf
  • hausa
  • huggingface
  • igbo
  • imatrix
  • llama.cpp
  • lora
  • mlx
  • mobile-money
  • nigeria
  • offline-ai
  • on-device-ai
  • pytest
  • python
  • qlora
  • quantization
  • qwen2.5
  • sqlite
  • tax-compliance
Share this project:

Updates

Submission history