Zero Labs
Industry News / AI

I Built a Finance AI That Proves Every Number It Gives You

Source · Towards AI By Govind Mudavadkar

From the publisher’s feed, collected in the ZeroLabs newsroom.

Chatbots invent numbers that look real. I trained a small, low cost AI to point to the exact line in a company’s annual report for every figure it uses. It matched GPT-5.5’s accuracy at about 600 times lower cost.Ask an AI chatbot what share of a company’s debt comes due after five years and you will get a confident number. Maybe it is right. Maybe it grabbed a figure from the wrong row or did the division in its head and slipped a digit. The answer looks exactly the same either way.In finance that is a deal breaker. An analyst an auditor or a controller cannot use a number they cannot trace back to the filing it came from.So I built LedgerMind a system where the AI is never allowed to write the final number.The short versionA small open AI model I trained (4 billion parameters small enough to run on a single GPU) answers 74.9% of FinQA test questions correctly, with every answer verified. The same model before training: 20.4%.It is statistically tied with OpenAI’s gpt-5.5 on the same questions at about 600 times lower cost per query.Made up figures fell from 46.6% to 1.7% and the verifier caught 100% of 7,212 deliberately corrupted answers.Everything is open: the code, every result file, a live dashboard and an audit explorer. Links are at the end.Why I built thisFinance runs on numbers that somebody has to sign off on. A chatbot’s answer may be right but there is no fast way to tell which answers are and checking one means redoing the work yourself. That makes a fast answer worth very little.I wanted to find out whether a small model could be trained to make checking cheap: show the exact cells it used, hand the math to calculator and let a strict checker have the final say. Not an AI that is always right but one whose mistakes you can see in seconds.A few terms, in plain English10-K: the annual report every US public company files full of financial tables.FinQA: a public set of questions about those reports written by finance experts with an answer key.SFT (supervised fine tuning): teaching a model by showing it thousands of worked examples.LoRA: a way to fine tune only a small add on to the model instead of all of it so training fits on one GPU.GRPO: a reinforcement learning method. The model tries several answers and the better ones are rewarded.Verifier: a strict program not an AI that checks every figure against the document.fp8: storing the model’s numbers with fewer bits so it runs faster on the same hardware.p value: how likely a gap this size is to be luck. Above 0.05, I call it a tie.The idea: the model proposes, a calculator computes, a verifier decidesLanguage models are good at reading. They are unreliable at multistep arithmetic and they are happy to invent number that sounds right. LedgerMind splits the job so each part does what it is good at.The model reads and cites. It points to the figures it needs cell by cell and writes a short formula. That is all it is allowed to output.A calculator computes. A small deterministic engine runs the formula. Same input, same answer, every time.A verifier decides. It checks that every cited figure is really printed where the model says it is. If any check fails the answer is refused with the reason instead of returned.Here is what the model actually wrote for that question. No final number anywhere, only pointers and a plan:{ "evidence": [ {"id": "e1", "value": 12806, "label": "thereafter", "source": {"type": "table", "row": 5, "col": 1}}, {"id": "e2", "value": 22258, "label": "total", "source": {"type": "table", "row": 6, "col": 1}} ], "plan": "e1 / e2", "answer_unit": "ratio"}The calculator runs e1 / e2 and gets 0.575. The verifier confirms that 12,806 is printed in the "thereafter" row and 22,258 in the "total" row. The answer ships as 57.5%, with receipts.Under the hoodThe verifier runs four gates on every answer:Provenance: each figure is printed exactly where it is cited. This catches fabricated numbers, wrong rows, wrong years, wrong signs and wrong scale.Plan hygiene: the formula really uses the cited figures. It even catches disguised constants like e1 - e1 + 12, a sneaky way to smuggle in an answer.Invariants: units, scale and period agree. No adding percentages to dollars, or millions to billions.Integrity: the table’s line items still add up to their totals, which flags documents that were tampered with.The design choice that matters most: the same verifier is the gate at answer time, the reward during training, and the scorer in evaluation. Training, serving and measurement can never disagree about what correct means.Teaching a small model to show its workI trained on FinQA, a public benchmark of 8,281 questions written by finance experts over real S&P 500 annual reports. I first converted every answer into cited figures plus a plan, which worked for 99.3% of the questions. Then I trained Qwen3–4B in two stages on a single NVIDIA H200 GPU.Stage 1: supervised fine tuningSupervised fine tuning (SFT) with a LoRA adapter taught the model the format: cite, plan, never compute. Two epochs took 67 minutes. Valid output jumped to 99.9% without any constrained decoding, and verified accuracy went from 20.4% to 74.5%.Stage 2: reinforcement learning, with the verifier as the rewardThen came GRPO, a reinforcement learning method in the RLHF family. Instead of a reward model trained on human preferences, the reward is the verifier itself, an approach known as reinforcement learning from verifiable rewards (RLVR). For each question the model writes eight answers, and the ones that are correct and properly cited score higher.Two details made it work. A filter kept only the 2,716 questions the model solved some of the time, because questions it always or never solves teach nothing. And the reward was built to resist gaming: citing real but irrelevant figures costs points, and a formula that does not depend on its evidence is penalised hard.The plot twistAfter 200 steps and almost four hours, greedy accuracy on the test set barely moved: +0.4 points, not significant. I almost called it a failure. Then I sampled answers the way they are generated during training, and the picture flipped.Sampled accuracy rose 7.1 points, and the questions the model got right on every try jumped from 552 to 784. GRPO did not teach new skills. It made the model reliably do what it already could, which matches published research on this kind of training. It also slightly narrowed how many questions the model could ever solve, and I report that too.Putting it against the giantsA small model beating other small models proves little. So I tested LedgerMind against five baseline models, nine configurations in all: OpenAI’s gpt-5.5 and gpt-5.4-mini, and two open models up to 120 billion parameters, gpt-oss-120b and Qwen3.8–27B. Each answered both directly and through my pipeline, and every comparison is paired on identical questions with significance tests.gpt-5.5, answering directly: tie (LedgerMind 1.75 points lower, p = 0.38), and gpt-5.5’s direct answers come with no verification.gpt-5.5 through the same pipeline: tie.gpt-oss-120b: LedgerMind wins both ways, by 2.9 points directly and 12.2 points through the pipeline.gpt-5.4-mini: LedgerMind wins both ways.Qwen3.8–27B: tie through the pipeline. Answering directly, Qwen3.8 wins by 2.7 points, using about eight times as many output tokens and with no verification. It is the one comparison LedgerMind loses, and I put it front and center.Trying to break itA verifier is only as good as the attacks it survives, so I built a red team for it, called the Saboteur. It attacks in three ways.Corrupted answers. Take a correct answer and break it the way language models really fail: a wrong digit, a wrong row, a flipped sign, a hardcoded result. The verifier caught all 7,212.Tampered documents. Change the filing itself. Answers based on the old figures are rejected 99.7 to 100% of the time, and the tampering is flagged whenever a printed total covers the changed cell.Counterfactual filings. Edit the figures in real 10-K filings, so a model that remembers the real filing gives the wrong answer. LedgerMind read the edited numbers: only 4 of 846 answers matched the real filing. gpt-oss-120b’s accuracy dropped 3.3 points on the edited documents, the clearest sign of a model recalling what it saw in training instead of reading.Watch it work liveI built a small demo app and ran the model live on an H200. Each answer took about half a second.Where it still failsHere is the honest part. Verified does not mean correct. The verifier proves that every figure in an answer is real and sits exactly where the model says it does. It cannot prove the model picked the right figures.Of the 1,107 test answers the verifier accepted, 254 were still wrong, about 1 in 4. Here is what went wrong in them:191: a real figure, but the wrong one, or the wrong formula. For example, the right row from the wrong year, or a difference where the question asked for a percent change. This is by far the biggest failure.19: the scale was off, such as thousands read as millions.16: the sign was flipped, a decrease reported as an increase.14: close but not close enough, within 5% of the answer key, often a rounding or definition difference.13: a percent change in the wrong direction, with the old and new values swapped.1: a yes or no question answered the wrong way.The other 32 answers were refused, so the system said no instead of being wrong. That tradeoff is the point of the design: a wrong but traceable answer can be caught by a person in seconds, because the cited cells are right there. A made up number cannot be caught that way.Two more failures I want to be upfront about.The benchmark is noisy too. In the refusal shown above, the dataset had flattened the filing’s table into a single row, so the model cited a cell that does not exist and the verifier refused. The twist: the model’s number was actually the true percentage change, and FinQA’s own answer key is wrong for that question. I report known bad labels like this one instead of quietly fixing them.The model never says “I don’t know.” Its training examples contained no refusals, so when a figure is missing from the document it answers anyway. Teaching it to abstain is the first item on my list of next steps.Who would actually use thisAnalysts and investment researchers who pull ratios out of filings and need to show where each one came from.Auditors and internal audit teams, where every figure in a workpaper needs a trail back to its source.Compliance and risk teams checking reports before they reach regulators or clients.Banks and fintech companies that cannot send client documents to an outside API. A 4 billion parameter model runs on one GPU inside their own data center.In every case, the value is not that the AI is always right. It is that a person can check it in seconds instead of redoing the work.Serving it fast and cheapServed with vLLM on one H200: 48.7 requests per second, about half a second per answer.fp8 quantization gave 9 to 20% more speed with identical accuracy, 74.89% in both bf16 and fp8.JSON schema constrained decoding halves peak throughput. The trained model produces valid JSON 99.9% of the time on its own, so it does not need it.Three times my results tried to flatter meThe part of this project I am proudest of is not a number. It is the bugs I caught that were making my model look better than it is.A scoring bug. Percent answers were checked against fraction answers with a tolerance that did not scale. It undercounted the API models by up to 3 points. Fixed, and every result rescored.A biased prompt. My pipeline prompt never defined argument order for its percent change function and asked for unit conversions that FinQA does not use. My trained model had learned the conventions; gpt-5.5 had not. I measured the bias at about 8 points and wrote a fixed version of the prompt.Hidden timeouts. Qwen3.8 thinks for over a thousand tokens per answer, and 271 of its requests timed out on my side. Rerunning them is how I learned it beats LedgerMind when answering directly.A result that survives you trying to break it is worth more than a bigger number.What was hardThe whole project took about three days, from an empty repository to the final results. Very little of that time went into the clever parts. Most of it went into the kind of friction every engineer on shared hardware will recognize.The queue. At one point 118 jobs were waiting ahead of mine for the H200 GPUs. I moved the open model baselines to A100s and split work into short jobs that slip into gaps in the schedule.A GPU that could not run the model at all. The older V100 cards had no compiled kernels in my PyTorch build, so every job failed on startup.Storage that was too slow to install on. Installing the Python environment on shared storage took forever, so each job builds it on the node’s local disk. Then two jobs on the same node corrupted each other’s install, which needed a file lock to fix.A silent proxy. The cluster routed every web request through a proxy, including requests to my own model server on the same machine, so they simply hung. One environment variable fixed it, after an afternoon of confusion.A job that said it was done and never stopped. Training printed its completion message and then hung, holding the GPU. Evaluations now start only after a check confirms the training output is complete.None of this shows up in a results table, but it is most of what training models on real infrastructure actually feels like.Questions you might be askingWhy not just give GPT a calculator tool?A calculator fixes the arithmetic, not the inputs. A model with a calculator can still feed it a figure from the wrong row, or one it made up, and the result looks just as confident. The verifier is the part that checks the inputs against the document, and that is what makes an answer traceable.Why train a small model instead of prompting a big one?Four reasons. Cost: about $0.022 per 1,000 queries against $12.90 for gpt-5.5. Privacy: financial documents never leave your own servers. Speed: about half a second per answer. Control: the model never changes underneath you, because you own the weights.Why not use RAG (retrieval augmented generation)?RAG solves a different problem. It finds the right page in a large pile of documents. LedgerMind makes sure the answer drawn from that page can be traced. FinQA hands the model the right page already, so retrieval was not needed here. In a real system the two work together, and retrieval over full filings is on my next steps list.Why GRPO, and not PPO or DPO?The verifier already gives every answer a clear score, so there is no need for pairs of preferred and rejected answers (what DPO needs) or for a separate value model (what PPO needs). GRPO simply compares eight answers to the same question and pushes the model toward the better ones. It is simpler and uses less GPU memory.Why Qwen3–4B?It has an open Apache 2.0 license, it is strong at reading tables for its size, and it is small enough to train with LoRA on a single GPU in about an hour.Why only 400 questions for gpt-5.5?Budget. I capped API spending at $20 and spent $16.52. Every comparison is still paired on identical questions; the cost is wider error bars, about 4 points either way on each accuracy. The self hosted open models ran on the full set of 1,139 questions.How did you compute the cost?For my model: a rented H200 at $3.80 per hour, running at its measured top speed. That is a best case, since real deployments rarely run at full load. For the API models: list price times the tokens each run actually used.Do reruns give the same answers?Yes, by design. Even at temperature 0, vLLM’s normal batching can change an answer slightly from one run to the next, which would add noise to the paired tests. Scored runs use its batch invariant mode, and two reruns gave identical outputs on all 1,139 questions, at about 2.2 times the generation time.Can I reproduce it?Yes. The repository has the cluster job scripts that produced every result, a locked environment file, and every result file, each tagged with the job and code version that made it.What it cost$16.52 in OpenAI API calls for the gpt-5.5 and gpt-5.4-mini baselines, with a hard $20 spending cap built into the code. I paid for these myself, because a comparison against the strongest model available was worth far more to me than the money.About 15 GPU hours in total: 7.8 on H200 for training and evaluation, 7.3 on A100 for the open model baselines.One laptop for development, the 299 tests and the dashboard.The tech stackTraining: SFT, GRPO with verifiable rewards, LoRA, TRL, PyTorch, Qwen3–4B.Serving: vLLM, fp8, batch invariant inference.Infrastructure: NVIDIA H200 and A100, CUDA, Slurm, Bash.Evaluation: paired McNemar tests, bootstrap confidence intervals, adversarial and counterfactual testing.Engineering: Python, pytest, GitHub Actions, GitHub Pages.What I would build nextTeach the model to refuse when a figure is missing from the document, instead of answering anyway.Refresh the training questions during reinforcement learning, so later steps keep learning instead of repeating solved problems.Move from single pages to retrieval over full filings, the way analysts actually work.Try it yourselfThe dashboard lets you click through 30 real questions and see every cited cell, the plan, the computed value and the verifier’s verdict. Every number in this article traces to a file in the repository.Live dashboard and audit explorer: govindrm7.github.io/LedgerMindCode, results and full write up: github.com/Govindrm7/LedgerMindIf you work on AI for finance, audit, risk or anything where a wrong number is expensive, I would love to hear from you. Connect with me on LinkedIn.I Built a Finance AI That Proves Every Number It Gives You was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.