Backprop Bulletin practical guide
Compare two models on the same workload for accuracy, latency and cost
A model that wins someone else's benchmark may still be the wrong choice for your task. This guide builds a small harness that sends the same labelled prompts to two models, scores every reply and reports accuracy, response time and cost side by side, with an honest measure of how sure you can be. Then a test you can run shows how easily a small workload ranks two models the wrong way round.
What you will build
The harness is one file, compare-models.mjs. It holds a workload of 30 short invented prompts, each with one correct answer, and it can:
- Send the workload to two models through an OpenAI-compatible chat completions endpoint, the kind llama.cpp's
llama-serverand many hosted services provide. It asks one model at a time, one prompt at a time, so the two never compete for the same computer. - Score every reply right or wrong, and report each model's accuracy with a range for how uncertain it is, its response times, the tokens it used and its cost, from prices you supply.
- Compare the two on the same items, which tells you more than two separate scores do.
- Resample the results to show how often a workload of a given size would put the models in a different order.
For the worked example, the harness starts two simulated models itself, sim://quick and sim://careful, and talks to them over HTTP on your own computer exactly as it would to a real endpoint. They are not language models: they give fixed replies after fixed waits, so you can check every figure in the report against what they were built to do.
Prerequisites and tested runtime
- Node.js 20 or later, with no packages and no build step. The harness uses Node.js's built-in
fetch. Tested with Node.js 24.22.1 and 22.23.5 on Linux, in Bash; the output shown here was the same on both. - An empty folder. The harness writes only the results file you name with
--out. With the simulated models it uses no network beyond your own computer (127.0.0.1).
Create an empty folder, open a terminal in it and download the harness into it:
Download compare-models.mjs JavaScript, 359 lines, 22.6 kB
Before running a downloaded file, read it. You can also check that you have the same file this guide was tested with:
Run
sha256sum compare-models.mjs
Expected output
729fac980ea5867abfd9331feda0f8c13509ac4d51e09b771aa3cc8efc762122 compare-models.mjs
On macOS, use shasum -a 256 compare-models.mjs instead.
The workload and how it is scored
The 30 prompts cover arithmetic, unit conversion, picking a fact out of a sentence, the sentiment of a short review and spotting the odd one out. All of them were written for this guide. Each asks for a one-word or one-number answer:
Run
node compare-models.mjs workload
Expected output (invented workload)
W01 expects "36" A box holds 12 pencils. How many pencils are in 3 boxes? Reply with the number only.
W02 expects "27" Mia had 45 stickers and gave away 18. How many does she have left? Reply with the number only.
W03 expects "95" A train leaves at 09:40 and arrives at 11:15. How many minutes does the journey take? Reply with the number only.
W04 expects "36" What is 15% of 240? Reply with the number only.
W05 expects "21" A recipe needs 3 eggs per cake. How many eggs are needed for 7 cakes? Reply with the number only.
W06 expects "8" A rope 50 metres long is cut into pieces 6 metres long. How many whole pieces are there? Reply with the number only.
W07 expects "7" Sam reads 14 pages a day. How many days does he need for a 98-page book? Reply with the number only.
W08 expects "50" What is 7 times 8, minus 6? Reply with the number only.
W09 expects "5" A shop sells 4 apples for 2 euros. How many euros do 10 apples cost? Reply with the number only.
W10 expects "8" The temperature was -3 degrees and rose by 11 degrees. What is it now? Reply with the number only.
W11 expects "negative" Is this review positive or negative? "The battery died after an hour." Reply with one word: positive or negative.
W12 expects "positive" Is this review positive or negative? "Setup took two minutes and it has worked perfectly since." Reply with one word: positive or negative.
W13 expects "negative" Is this review positive or negative? "I would not buy this again." Reply with one word: positive or negative.
W14 expects "positive" Is this review positive or negative? "The staff went out of their way to help us." Reply with one word: positive or negative.
W15 expects "positive" Is this review positive or negative? "Not bad at all, better than I expected." Reply with one word: positive or negative.
W16 expects "negative" Is this review positive or negative? "It looks great, but it stopped working within a week." Reply with one word: positive or negative.
W17 expects "1932" Extract the year: "The bridge at Larkford opened to traffic in March 1932 after six years of work." Reply with the year only.
W18 expects "ana" Extract the first name: "Please send the invoice to Dr Ana Ruiz at the Harbour Street office." Reply with the first name only.
W19 expects "green" What colour is the car? "The delivery van was white, but the car parked behind it was green." Reply with one word.
W20 expects "kx-4471" Extract the order number: "Your order KX-4471 will arrive on Tuesday." Reply with the order number only.
W21 expects "oxden" Which town is the meeting in? "We moved the meeting from Brackley to Oxden because of the rail strike." Reply with the town only.
W22 expects "4" How many people are on the guest list? "The guest list has Priya, Tom, Lena and Omar." Reply with the number only.
W23 expects "carrot" Which word does not belong: apple, banana, carrot, cherry? Reply with the word only.
W24 expects "trumpet" Which instrument does not belong: violin, trumpet, cello, guitar? Reply with the word only.
W25 expects "vegetable" Where are tomatoes sold in this shop? "In our shop, tomatoes are in the vegetable aisle." Reply with one word: fruit or vegetable.
W26 expects "stones" Which is heavier: 1 kilogram of feathers or 2 kilograms of stones? Reply with one word: feathers or stones.
W27 expects "210" How many minutes are in 3.5 hours? Reply with the number only.
W28 expects "240" How many centimetres are in 2.4 metres? Reply with the number only.
W29 expects "1750" How many grams are in 1.75 kilograms? Reply with the number only.
W30 expects "720" How many seconds are in 12 minutes? Reply with the number only.
A reply is right only if, after a little tidying, it is exactly the expected answer. Capital letters, spaces at either end, quotation marks around it, a full stop at the end and commas in numbers such as "1,750" are ignored:
const normalise = (s) => String(s ?? "").trim().toLowerCase().replace(/^["'`]+|["'`]+$/g, "").replace(/[.!]+$/, "").replace(/(\d),(?=\d{3}\b)/g, "$1").replace(/\s+/g, " ").trim();
const isCorrect = (reply, answer) => normalise(reply) === answer;
That is strict on purpose. "The journey takes 95 minutes." contains the right number but is not the answer the prompt asked for, and a program that reads the reply would fail on it. The report counts such near misses separately, so you can tell a model that knows the answer but ignores the format from one that gets it wrong. Whatever rule you choose is part of the result: change the rule, and the accuracy changes with it.
Run the comparison
The two simulated models are defined in one table. Each gives the correct answer to every prompt except those listed, and waits longer for longer prompts:
const SIMULATED = {
quick: { waitsMs: [150, 250, 350], replies: { W06: "9", W08: "14", W09: "4", W15: "negative", W16: "positive", W24: "guitar", W27: "330", W29: "175" } },
careful: { waitsMs: [350, 450, 550], replies: { W03: "The journey takes 95 minutes.", W16: "positive", W20: "4471", W24: "guitar" } },
};
So quick is wrong on 8 items and careful on 4, and careful is slower. They count one token for every four characters, rounded up. Every prompt goes out as one chat completion, at temperature 0 and with room for a 32-token reply, and is timed from sending the request to receiving the whole answer:
body: JSON.stringify({ model: model.model, messages: [{ role: "user", content: prompt }], temperature: 0, max_tokens: 32 }),
Before the timed prompts, each model gets one request that is not scored or timed, so that setting up the connection is not counted against the first item:
const warm = await ask(m, WORKLOAD[0].prompt); // one unscored warm-up request, so connection set-up is not timed as item 1
Each model is described by a list of settings: a name, an address (here, a simulated one) and one price basis. The prices here are invented for this example; they are not any provider's. quick is priced like a model on your own machine, by the hour, and careful like a hosted service, by the million tokens. The run takes about 22 seconds:
Run
node compare-models.mjs run --a "name=quick,url=sim://quick,per-hour=0.40" --b "name=careful,url=sim://careful,in-per-m=0.50,out-per-m=1.50" --out results.json
Expected output (simulated models)
workload: 30 of 30 invented prompts; each reply scored right or wrong against its expected answer
model A: quick (simulated); model B: careful (simulated)
A quick B careful
accuracy 22 of 30 (73%) 26 of 30 (87%)
95% interval 56% to 86% 70% to 95%
latency p50 0.3 s 0.5 s
latency p95 0.4 s 0.6 s
total request time 8 s 14 s
input tokens 768 768
output tokens 44 50
price basis $0.40 per hour $0.50 in, $1.50 out per M
cost per 1,000 prompts $0.030 $0.015
only A right: 2 (W03, W20); only B right: 6 (W06, W08, W09, W15, W27, W29)
exact McNemar test on those items: p = 0.29
careful is ahead by 4 of 30.
Chance alone often gives a gap this large (p is 0.05 or more): on these items the two are not clearly different.
careful: 1 wrong reply contains the expected answer among other words; check the scoring rule
per-item results written to results.json
Reading the report, line by line:
- accuracy: 22 and 26 right, exactly as the simulated models were built.
- 95% interval: the range of true accuracies that fits this many right answers out of 30 (see the next section). The two ranges overlap widely.
- latency p50 and p95: the median response time and the 95th percentile. With 30 items, p50 is the 15th fastest response and p95 the 29th, the second slowest. The simulated waits of 250 and 350 ms for
quick, plus a few milliseconds of HTTP, round up to 0.3 and 0.4 s. - total request time: all 30 response times added together, in whole seconds.
- input and output tokens: as the endpoint reported them in each answer's
usage. Here both simulated models count the same way; real models with different tokenisers do not. - price basis and cost per 1,000 prompts: worked out from the figures above, as shown in "How cost is worked out" below.
- only A right, only B right: the items on which the two models disagree. They decide the comparison; the items both got right or both got wrong say nothing about which is better.
- near misses:
careful's reply to W03 contains 95 but is a sentence, so it is scored wrong and flagged.
The per-item results, including every reply and response time, are in results.json.
How sure can you be?
With 30 items, every right or wrong answer moves accuracy by more than three percentage points, so a single score says little on its own. The harness gives two measures of how much to trust it.
The 95% interval is the Wilson score interval, a standard way to put a range around a proportion measured on few items:
function wilson(k, n, z = 1.96) {
const centre = (k + (z * z) / 2) / (n + z * z);
const half = (z / (n + z * z)) * Math.sqrt((k * (n - k)) / n + (z * z) / 4);
return [Math.max(0, centre - half), Math.min(1, centre + half)];
}
For 22 right out of 30 it runs from 56% to 86%: thirty points wide. Two models whose intervals overlap this much have not been told apart.
The exact McNemar test uses the fact that both models answered the same items. McNemar's test, from his 1947 paper on the difference between proportions measured on the same cases, looks only at the cases where the two differ. Here there are 8 such items, split 2 to 6. The exact form of the test asks how often 8 tosses of a fair coin would split at least that unevenly, either way:
function mcnemarExact(b, c) {
const n = b + c;
if (n === 0) return 1;
let tail = 0;
let choose = 1;
for (let i = 0; i <= Math.min(b, c); i += 1) {
tail += choose;
choose = (choose * (n - i)) / (i + 1);
}
return Math.min(1, (2 * tail) / 2 ** n);
}
The answer, p = 0.29, means about 29 times in 100. If the two models were equally good on items like these, a gap this large would still be common, so 30 items cannot settle it. The harness says so instead of declaring a winner.
How cost is worked out
The harness supports two price bases, and works out the cost of the run from whichever you give:
const cost = model.perHour !== undefined ? (busyS / 3600) * model.perHour
: counted ? (tokensIn / 1e6) * model.inPerM + (tokensOut / 1e6) * model.outPerM : null;
- A model on your own machine (
per-hour=): cost = total request time in seconds ÷ 3,600 × the machine's price per hour. Forquick: 8 s ÷ 3,600 × $0.40 = $0.00089 for 30 prompts, or $0.030 for 1,000 prompts like these. The hourly price is yours to work out, for example from the rent of a cloud machine, or from your own hardware's cost spread over its useful life plus electricity. This assumes you pay only while the machine is answering; if it sits idle between jobs, the real cost per prompt is higher. - A hosted service (
in-per-m=andout-per-m=): cost = input tokens ÷ 1,000,000 × the input price + output tokens ÷ 1,000,000 × the output price. Forcareful: (768 × $0.50 + 50 × $1.50) ÷ 1,000,000 = $0.00046 for 30 prompts, or $0.015 for 1,000. Take the prices from the provider's current price list for the exact model you use.
The table rounds costs to two significant figures, and the time-based cost uses the total request time as shown, in whole seconds, so you can recompute every cost from the rows above it. The token counts are the ones the service reports. Some services count tokens you do not see in the reply: OpenAI's API reference, for example, breaks its completion token count down into details that include reasoning tokens.
A limitation you can test: when the ranking flips
The simulated careful model is the more accurate one by construction: 26 right against 22 on the full workload. Now compare the two on 10 of the 30 items, chosen at random with seed 26:
Run
node compare-models.mjs run --a "name=quick,url=sim://quick,per-hour=0.40" --b "name=careful,url=sim://careful,in-per-m=0.50,out-per-m=1.50" --items 10 --seed 26
Expected output (simulated models)
workload: 10 of 30 invented prompts (chosen with seed 26); each reply scored right or wrong against its expected answer
model A: quick (simulated); model B: careful (simulated)
A quick B careful
accuracy 9 of 10 (90%) 8 of 10 (80%)
95% interval 60% to 98% 49% to 94%
latency p50 0.3 s 0.5 s
latency p95 0.4 s 0.6 s
total request time 3 s 5 s
input tokens 255 255
output tokens 15 21
price basis $0.40 per hour $0.50 in, $1.50 out per M
cost per 1,000 prompts $0.033 $0.016
only A right: 2 (W03, W20); only B right: 1 (W08)
exact McNemar test on those items: p = 1.00
quick is ahead by 1 of 10.
Chance alone often gives a gap this large (p is 0.05 or more): on these items the two are not clearly different.
careful: 1 wrong reply contains the expected answer among other words; check the scoring rule
On these 10 items the worse model wins, 90% to 80%. Seed 26 was picked to show this happening, so it says nothing yet about how often it happens. To find that out, the resample command uses the bootstrap: it draws new workloads from the 30 items you already ran, with replacement, rescores both models on each and counts which comes out ahead. No model is called again:
diff += Number(ra[i].correct) - Number(rb[i].correct);
Run
node compare-models.mjs resample --in results.json --size 10
Expected output (simulated models)
10,000 resampled workloads of 10 items, drawn with replacement from the 30 items in results.json
quick ahead: 1,183 (12%)
tied: 1,888 (19%)
careful ahead: 6,929 (69%)
With 10 items, almost a third of workloads would not show the better model ahead. At the size you actually ran:
Run
node compare-models.mjs resample --in results.json
Expected output (simulated models)
10,000 resampled workloads of 30 items, drawn with replacement from the 30 items in results.json
quick ahead: 500 (5%)
tied: 491 (5%)
careful ahead: 9,009 (90%)
Even at 30 items, one workload in ten would not have ranked careful first. And with more items of the same kind:
Run
node compare-models.mjs resample --in results.json --size 100
Expected output (simulated models)
10,000 resampled workloads of 100 items, drawn with replacement from the 30 items in results.json
quick ahead: 18 (0.2%)
tied: 23 (0.2%)
careful ahead: 9,959 (99.6%)
This is where the method stops being reliable, and roughly how far it can be pushed. A gap of four items out of 30 is not enough to choose a model on. About a hundred items like these would very likely rank the two correctly. Treat that last figure as a planning estimate, not a result: resampling can only reuse the 30 items you have, so it cannot tell you about kinds of prompt the workload leaves out.
With real models
These steps compare two versions of the same small open-weight model, a smaller and a larger file, on your own machine. Backprop Bulletin did not run these steps for this guide: no real model was downloaded or compared, and no figures for real models appear on this page.
- Get llama.cpp and the first model by following steps 1 to 5 of our guide to running a small model locally. You will have
llama-b12359/llama-serverandQwen3.5-0.8B-Q4_0.gguf, both checked against their SHA-256. - Download the second model from the same repository and revision (833,592,096 bytes), and check it against the SHA-256 that Hugging Face lists on the file's page. The second command should print
Qwen3.5-0.8B-Q8_0.gguf: OK:curl -L -o Qwen3.5-0.8B-Q8_0.gguf https://huggingface.co/ggml-org/Qwen3.5-0.8B-GGUF/resolve/004fd086eccea9f7cf867aa07ba328773beef81d/Qwen3.5-0.8B-Q8_0.gguf echo "37ae482d336108d23516fa35e8e0c4126688d81018b87178a18d752a1357814f Qwen3.5-0.8B-Q8_0.gguf" | sha256sum -c - Start one server for each, in the background, and wait until both answer
/health.--aliasgives each model the name the harness will ask for. You need memory for both models at once:./llama-b12359/llama-server -m Qwen3.5-0.8B-Q4_0.gguf --alias q4 -c 4096 --port 9931 --no-ui --offline > q4.log 2>&1 & ./llama-b12359/llama-server -m Qwen3.5-0.8B-Q8_0.gguf --alias q8 -c 4096 --port 9932 --no-ui --offline > q8.log 2>&1 & until curl -sf http://127.0.0.1:9931/health > /dev/null && curl -sf http://127.0.0.1:9932/health > /dev/null; do sleep 1; done - Run the comparison, with your machine's price per hour in place of
PRICE, then resample the results:node compare-models.mjs run --a "name=q4,url=http://127.0.0.1:9931/v1,model=q4,per-hour=PRICE" --b "name=q8,url=http://127.0.0.1:9932/v1,model=q8,per-hour=PRICE" --out real.json node compare-models.mjs resample --in real.json - Stop both servers when you have finished:
kill %1 %2in the same terminal.
Shape of the output (not a measurement: your figures replace the words in angle brackets)
workload: 30 of 30 invented prompts; each reply scored right or wrong against its expected answer
model A: q4; model B: q8
A q4 B q8
accuracy <k> of 30 (<%>) <k> of 30 (<%>)
95% interval <low> to <high> <low> to <high>
latency p50 <seconds> <seconds>
latency p95 <seconds> <seconds>
total request time <seconds> <seconds>
input tokens <count> <count>
output tokens <count> <count>
price basis $<PRICE> per hour $<PRICE> per hour
cost per 1,000 prompts $<cost> $<cost>
only A right: <count> (<items>); only B right: <count> (<items>)
exact McNemar test on those items: p = <p>
<which model is ahead, and whether chance alone often gives a gap that large>
Read the replies in real.json as well as the scores. If a model answers with a sentence instead of a single word, the near-miss line tells you how often. The Q8_0 file is larger than the Q4_0 file (834 MB against 563 MB), so expect it to need more memory; whether it is also slower, or more accurate on your prompts, is exactly what the comparison is for.
A hosted service
To compare with a hosted model, give its OpenAI-compatible address, the model's name, the name of an environment variable that holds your API key, and its prices per million tokens. Read the key into the variable without it appearing on screen or in your shell history:
read -rs MY_API_KEY && export MY_API_KEY
node compare-models.mjs run --a "name=q4,url=http://127.0.0.1:9931/v1,model=q4,per-hour=PRICE" --b "name=hosted,url=https://API-HOST/v1,model=MODEL-ID,key-env=MY_API_KEY,in-per-m=INPUT-PRICE,out-per-m=OUTPUT-PRICE" --out mixed.json
This sends the 30 invented prompts to that service; if you replace them with your own material, check first that you may send it there. The harness sends max_tokens and temperature, parameters of the OpenAI chat completions API. OpenAI's API reference marks max_tokens as deprecated in favour of max_completion_tokens and says it does not work with some of its models. If a service rejects the request, the harness stops after the warm-up request and shows the HTTP status; adjust the request body in the ask function to suit it.
Clean up
The worked example wrote only results.json. Delete it and the harness, and, if you followed the real-model steps, the other results, logs and model files:
rm -f results.json compare-models.mjs real.json mixed.json q4.log q8.log Qwen3.5-0.8B-Q8_0.gguf
The cleanup step of the other guide removes llama.cpp and the first model. If you exported an API key, end the terminal session or run unset MY_API_KEY.
What this does not do
- It does not know your task. Thirty invented prompts with one-word answers say nothing about your documents, your users or your language. Replace the workload with items from your real use, with answers checked by someone who knows them, and use more of them than you think you need.
- It scores only short, exact answers. Free-form answers, such as summaries or code, need a different way of scoring.
- It sends one request at a time. Response times when many requests arrive at once can be very different, and this harness does not measure them.
- One run is one sample. A hosted service's response time includes the network and whatever else the service is doing at that moment, and even at temperature 0 a model may not give the same reply every time. Run the comparison more than once before you rely on it.
- The cost is an estimate. It rests on prices you supply and, for your own machine, on the assumption that you pay only while it is busy.
- It is a teaching example. It has no retries, no rate limiting and no tests of its own beyond the commands on this page.
Sources
Technical statements on this page were checked against these primary sources on 18 November 2026:
- E. B. Wilson (1927), "Probable inference, the law of succession, and statistical inference", Journal of the American Statistical Association 22(158): 209–212: the score interval for a proportion.
- Q. McNemar (1947), "Note on the sampling error of the difference between correlated proportions or percentages", Psychometrika 12(2): 153–157: comparing two proportions measured on the same cases.
- B. Efron (1979), "Bootstrap methods: another look at the jackknife", The Annals of Statistics 7(1): 1–26: resampling with replacement from the observed data.
- OpenAI API reference: create chat completion: the
usageobject withprompt_tokensandcompletion_tokens, its breakdown that includes reasoning tokens, andmax_tokensdeprecated in favour ofmax_completion_tokens. - llama.cpp: llama-server documentation: the OpenAI-compatible chat completions endpoint and its
usageobject,GET /health,--alias,--port,-c,--no-uiand--offline. - Hugging Face: ggml-org/Qwen3.5-0.8B-GGUF: the Q4_0 and Q8_0 files, their sizes and SHA-256 values.
- Node.js: fetch and AbortSignal.timeout(): the built-in HTTP client and the two-minute limit on each request.