Peter Parker

Project 06: Frontier Quality at a Fraction of the Bill

Measured, priced and dated, and reproducible from the repository

When does a small model you own beat paying per call?

Plenty of AI work is the same narrow task, run thousands of times: read a document, pull out the same fifteen numbers, put them in a database. The default is to pay a frontier model per call for it, and the alternative, a small model you run yourself, is rarely measured on the same documents. This project fine-tuned three small open models to read company financial filings, graded every answer against the figure the company itself filed, and rented the hardware to serve them, so quality is compared with quality and dollars with dollars.

of fields right, from a 2B model on filings published after it was trained
per 1,000 filings read on one rented card
filings a month and owning it pays against the cheapest API that does the job
filings a month against the API it matches the most accurate frontier result measured

Every figure on this page is read from the project's own results file, written by the same code that writes the repository's tables. See how it's built, in four diagrams.

The task, and how it is marked

Every US public company files its quarterly and annual reports with the SEC, and tags the key figures in them in a machine-readable format called XBRL. The model gets the financial statements as text and has to return fifteen fields: revenue, net income, total assets, earnings per share, the auditor, and so on.

The tags are the answer key. No model marks another model's work: each answer is compared with the figure the company filed, by code. Where a filing does not report a field, the right answer is "not reported", and a model that makes a number up is wrong.

The headline test set is filings published after the small models' training data was collected, from companies none of the training filings came from, so a good score cannot be memory.

period_end              date
fiscal_period           FY, Q1, Q2 or Q3
revenue                 US$
cost_of_revenue         US$, or not reported
operating_income        US$, or not reported
net_income              US$
eps_basic               US$ a share, or not reported
eps_diluted             US$ a share, or not reported
shares_diluted          a count, or not reported
total_assets            US$
total_liabilities       US$, or not reported
cash_and_equivalents    US$
stockholders_equity     US$
auditor_name            a name, or not reported
state_of_incorporation  a code, or not reported

The models, and exactly how they were fine-tuned

Three open-weights base models, one small, one middling and one large for this kind of work, each chosen for two things before quality: a licence that allows publishing the trained weights, and a documented training cutoff, so the test filings can be shown to postdate everything the model read. Each was fine-tuned with QLoRA: the base model's weights are frozen and stored in 4 bits, and only small low-rank "adapter" matrices added beside every attention and feed-forward projection are trained. That is what lets a 7B model train on one 24 GB card in a few hours rather than on a cluster.

How each recipe was chosen

From one starting recipe, one setting at a time was changed: the adapter's rank, the learning rate, and how many training filings it saw. Every run was then merged, served and graded on validation filings it never trained on, and each size kept the setting with the most fields right. The validation loss would have picked differently: for one size its lowest-loss run was its least accurate, because the loss is averaged over every character of an answer that is mostly punctuation and field names, and which number lands in a field is a few characters of it.

From filing to served model

  1. 1Pair each filing with its answer. The financial statements as text, and the fifteen figures the company tagged in XBRL, as the exact JSON the grader marks. Companies never cross from training into a test set.
  2. 2Train on the answer only. The loss falls on the model's reply and not on the instructions or the filing, so it learns to read, not to recite the prompt. It is trained on the zero-shot prompt, so no worked examples are paid for on every call afterwards.
  3. 3Checkpoint from the first steps. Rented cards can be taken back. Every checkpoint goes to object storage and a run resumes from its newest, which happened for real when a host rebooted mid-sweep.
  4. 4Merge, and check the merge. The adapter is folded into the base in 16-bit, and the merged model has to predict the same next tokens as base plus adapter on a held-out filing before it is used.
  5. 5Quantise, and measure what it costs. GGUF, AWQ and GPTQ versions, each graded against its own 16-bit model on the same filings and published with that loss stated; the two that lost the most, one of which forgot the output format altogether, were not published.
  6. 6Serve and publish. vLLM on a rented card behind the same gateway as the frontier APIs, so both are costed one way, and the weights, adapters and cards on Hugging Face.

The dearest API's accuracy, at a fraction of the cheapest one's price

Each mark is one model, its share of fields right against what 1,000 filings cost it, with its 95% interval as a whisker. The frontier APIs are what their vendors billed through the project's gateway. The fine-tunes are the card's hourly rent over the requests it served a second, measured with 32 requests in flight, with the card busy half the time. Cost runs along a log scale: each gridline is ten times the last.

Frontier API, per call Fine-tuned, on a rented card

Point at a mark for its figures.

Your break-even

An API is paid by the call. A card is rented by the hour, whether it serves one call or its fill. So below some volume the API is cheaper, and above it the card is. Put in what you pay and how hard you would run the card; the measured throughput does the rest.

Or price the API at a run this project measured
calls a month and the card is the cheaper
per 1,000 on the card, at this load
a month on the API at your volume
a month on cards at your volume
API, by the call Rented cards, by the month Your volume
The monthly bill on each against the volume. The cards' bill is a staircase: a whole card's month is paid as soon as the volume needs one more. The break-even is where the API's line first meets it.

What this leaves to you. The rent is the only cost counted unless you add one. The throughput is what the card was measured serving, on these filings, at 32 requests in flight; a card you rent for a different model or longer documents will serve a different number. And "how busy" is a choice: traffic that arrives in bursts, or a tight latency target, means a card that sits idle more of the month, and every call it does serve carries more of the rent.

Every card measured, across how busy it is

Calls a month at which one card first costs no more than the API, as the project's own code works it out. Where it says "never", the card at that load already costs more per call than the API does, so no volume helps.

Where it falls short

An average can hide a field that got worse. So every fine-tune went through a release gate field by field: it passes a field only if the whole 95% interval of the difference sits above a three-point loss, after correcting for testing fifteen fields at once.

What did not work

Three designs that looked right until they were measured. The full record is in docs/rejected.md.

Labels written by a frontier model

The usual shortcut when there is no answer key. Trained on gpt-5.6-luna's answers instead of the filed figures, the same 2B recipe scored below the model it learned from and picked up luna's habit of inventing values the filing does not report.

One tolerance for grading and for finding a label

A label counted as found when a number within the grader's half percent was on the page. The 200-item hand audit found labels taken from the wrong line, so a label now needs the printed figure at its own precision.

Prompting the base models instead of training them

The best untuned base, the 4B with reasoning on, scored well below gpt-5.6-luna and took far longer per filing.

What this does not show

How it is engineered

Every table, the chart and this page's results file come from the same stored runs, one command each. CI checks the calculator's JavaScript against the Python.

How this was built

I designed this project and made the calls in it. The one that mattered most was what to train on. The usual shortcut is to have a frontier model write the labels; I trained on the companies' own XBRL facts instead, and then measured the shortcut to be sure. It scored lower than the model it learned from and copied that model's habit of inventing answers the filing does not contain. I chose each recipe by serving and grading every run on validation filings, because the training loss would have picked the least accurate run for one size, and I ran two more seeds before believing a difference of half a point. Where the small model falls short, field by field, the page says so.

I used an AI coding assistant (Claude Code) for implementation and drafting, which is now standard practice in software, data science and machine learning work. Every number on this page is read from a results file written from the same runs as the repository's tables, and can be reproduced from the repository with one command and a GPU.

Glossary
Adapter
A small set of extra weights trained beside a frozen model. QLoRA trains only these, which is why a 7B model fits on one 24 GB card.
bf16
16-bit numbers, the full-precision form each model was merged to and the reference its smaller formats are checked against.
Break-even
The monthly volume at which a rented card costs no more than paying an API per call.
Confidence interval
The range a measured share would plausibly fall in if the test were repeated on other filings. Here 95%, resampled over filings.
Fine-tuning
Training an existing model further on one task, here reading fifteen fields from financial statements.
Frontier model
One of the largest, most capable models, sold by the call through an API.
Non-inferiority
A test that a new model is no worse than another by more than a set margin, here three points, on each field separately.
QLoRA
Fine-tuning with the base model stored in 4 bits and frozen, training only small adapters.
Quantisation (GGUF, AWQ, GPTQ)
Storing a model's weights in fewer bits so it is smaller and cheaper to serve. Each format here is graded against its own bf16 model.
Requests in flight
How many requests the card is working on at once during the load test: for the published costs.
XBRL
The machine-readable tags US public companies put on the key figures in their SEC filings. Here they are the answer key.
Zero-shot, two-shot
Asking a model with no worked examples in the prompt, or with two.