← Back to the homepage

Backprop Bulletin practical guide

Compare two models on the same workload for accuracy, latency and cost

Illustration: one stack of prompt cards feeds two model chips, and paired bars compare the two models on correct answers (a check mark), response time (a stopwatch) and cost (a coin).

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.

By Backprop Bulletin.Comment on this guide Tested on 18 November 2026 with Node.js 24.22.1 and 22.23.5 on Linux.

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:

  1. Send the workload to two models through an OpenAI-compatible chat completions endpoint, the kind llama.cpp's llama-server and 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.
  2. 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.
  3. Compare the two on the same items, which tells you more than two separate scores do.
  4. 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

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:

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;

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.

  1. 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-server and Qwen3.5-0.8B-Q4_0.gguf, both checked against their SHA-256.
  2. 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
  3. Start one server for each, in the background, and wait until both answer /health. --alias gives 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
  4. 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
  5. Stop both servers when you have finished: kill %1 %2 in 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

Sources

Technical statements on this page were checked against these primary sources on 18 November 2026:

About this guide. It was written for this site by Backprop Bulletin with AI assistance. Every checked command above was run as shown, and each expected output is copied from that run; an automated check runs them again. The steps with real models were not run by Backprop Bulletin for this guide. No outside expert has reviewed it. The worked example uses invented prompts and two simulated models. It needs no account, key, network connection or paid service, and it sends nothing anywhere.