Skip to main content Switch to mobile version ai-rank 1.0.2 Ranking of AI Systems by the Accuracy-Resource Trade-off
pip install ai-rank Copy PIP instructions
Ranks neural networks by the accuracy–resource trade-off and returns one score per model. There is no weight to choose: the exchange rate between accuracy and cost is derived from the candidates' own frontier.
Nothing is declared by hand — no price, no grain, no chance level. The only argument is --alpha, a coverage convention.
Create and Activate a Virtual Environment (recommended)
python3 -m venv .venv source .venv/bin/activate python -m pip install --upgrade pip For Windows:
python3 -m venv .venv .venv\Scripts\activate python -m pip install --upgrade pip python -m pip install --upgrade pip pip install -r requirements.txt Use as an API
The API is two functions, and they are the two halves of one operation: derive a price from candidates, or reuse a price already derived.
Nothing else is public. They share one charging kernel, so a model ranked either way gets the same score, sigma and eps_eff — identical by construction, not by agreement.
What select() does and score() does not: derive a price, test the floor, and report a verdict, an interval, a band or a regret. There is nothing to verify at a price you supply, so score() returns the ranking alone. score() needs one model; select() needs enough of a frontier to price.
import pandas as pd from ab.nn.select import select df = pd.DataFrame({ "name": ["B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7"], "accuracy": [0.771, 0.791, 0.801, 0.816, 0.829, 0.836, 0.840, 0.843], "flops_B": [0.39, 0.70, 1.0, 1.8, 4.2, 9.9, 19, 37], "params_M": [5.3, 7.8, 9.2, 12, 19, 30, 43, 66], }) r = select(df, res_col=["flops_B", "params_M"], rank=True) r["winner"]["name"] # 'B0' <- the selected model r["winner"]["score"] # 0.8024 <- its score, higher is better r["verdict"]["level"] # 'USABLE' | 'UNVERIFIED' | 'UNUSABLE' r["ranking"] # DataFrame: name, score, rank, ... r["band"]["members"] # ['B4', 'B0'] <- what a price in the interval can pick r["minimax"]["regret"] # worst-case regret per candidate, in nats Input
One row per model, in a pandas.DataFrame:
select(df, res_col=...) names the resource column(s) — a string for one, a list for several. All models must be measured on the same test set and the same device, and each resource in one fixed unit.
Quality that is not already in (0, 1) must be converted first. For PSNR in dB, accuracy = 1 - 10 ** (-PSNR / 10). For top-1, mAP, mIoU, SSIM or F1, use the value as it is.
select() returns a dict. The three things most users need:
Also returned: verdict, status, prices (one price per resource axis), rate, price_free (dominations true at every price), jet (the curve read from three accuracies), rung (the fit-free third-order test), front, fit, envelope, axis_drop, next, notes, problems. select() prints nothing and raises nothing; bad input comes back as status="bad_input" with the offending rows listed in problems.
score = 1 / (1 + eps_eff) eps_eff = eps * product over axes of (resource ** lambda) eps = 1 - accuracy eps_eff is the error the model effectively costs once its resources are charged at the derived price lambda; score is that mapped into (0, 1) so that higher is better.
Its one useful property: it is computed from a single model's own accuracy and resources, and from nothing else. Adding or removing other models cannot change it — unlike rank, or any score normalised over the candidate set. So scores are comparable across runs and across published tables.
Two things it is not invariant to:
the resource unit — milliseconds vs seconds shifts every score by the same constant, so the ordering is untouched but the numbers are not comparable unless the unit is fixed;
lambda — only compare scores derived at the same price.
select() derives the price from the models it is given, so a model measured later (a new candidate, a re-run) cannot be compared by calling select() again: the price would be re-derived with it in the set, and scores are comparable only at the same price. score() charges any frame at a price fixed earlier instead:
from ab.nn.select import select, score r = select(reference, res_col="latency_ms") # derive the price once s = score(new_models, r, res_col="latency_ms") # reuse it: DataFrame, best first s = score(new_models, 1.04, res_col="latency_ms") # or give lambda directly The price is a select() result, a float for one resource, or a {axis: lambda} dict for several. On the command line: --price 1.04, or --price p1=0.5 --price p2=0.2 for several resources.
score() returns a DataFrame, best first: name, score, rank, accuracy, each resource, sigma, eps_eff — the same columns and the same numbers select()'s ranking carries at that price. Rows that fail validation are dropped and listed in .attrs["problems"]; the price used is in .attrs["price"]. It raises ValueError only for a price or columns it cannot use.
No verdict is returned, and that is not an omission: a price you supplied is not a measurement this data can confirm or reject. Read the verdict from the select() run that derived the price, once.
Why a model loses: the regret splits in two
sigma says which model wins. It does not say why a model lost — whether it wasted its budget or simply had the wrong budget. Those are different failures and they are now reported apart, in nats, as an exact identity rather than a weighting.
Write beta = lambda/alpha for the declared share and p(x) for the share the fitted frontier carries at log-budget x. At price lambda the frontier's own optimum sits where p(x) = beta, and then for any candidate, on the curve or below it:
sigma* - sigma_i = [ S_f(x_i) - S_i ] + KL( beta || p(x_i) ) '--- shortfall --' '--- displacement ---' shortfall_nats — nats below the fitted curve at this model's own budget: what it wastes. This is the one thing sigma cannot see, because sigma charges a model for what it spends: a model far below the curve can still win on being cheap.
displacement_nats — KL(beta || p(x)), the regret of operating away from where this price is in equilibrium with the frontier. At the canonical lambda = alpha/2 it is exactly ln cosh(alpha (x - x*) / 2).
Both terms are differences of the same scalar sigma, so they are the same nats by construction and add with weight one: there is no exchange rate left to declare between them. And because the sum is sigma* - sigma_i, with sigma* the same for every candidate, these columns read the ranking rather than altering it. The ranking, the winner, the band and every price are untouched.
Reading the EfficientNet example: B7 loses 0.43 nats, of which 0.41 is displacement — it is not wasteful, it is 37x past where this price pays. B0 loses 0.15 nats, essentially all of it shortfall — it sits furthest below the curve.
One resource axis only: with several, each axis is fitted alone and there is no single frontier to measure a candidate against; the columns are then absent.
The missing ceiling. eps = eps_inf + c t^-alpha has a floor but no ceiling: pushed far below the budgets it was fitted on it predicts eps > 1, an error no normalised quality can reach, and a model that "beats" that promise collects credit for it. A curve may not promise worse than the trivial bound, so the prediction is capped at eps = 1. The cap is a fact about the measure, not a tuning constant, and it binds only where the law has left the range of anything it could describe. Where it binds the regret is larger — the credit is withheld — and the identity above is what gives way, not the honest shortfall.
Read the verdict before the ranking
verdict["level"] says whether the ranking means anything. A clean run prints nothing; a problem prints in red, first.
UNVERIFIED and UNUSABLE still return a full ranking — labelled, not withheld. What holds regardless of the verdict is price_free: a model beaten on accuracy and on every resource can never win at any price. So does the band: it is built from the envelope, which needs no rate, no floor and no fit.
A second, independent floor verdict comes from rung["floor_sign"], which is read from four accuracies with no fit at all — see the rung below. It is the one verdict the F-test cannot give below four points.
The optimum is a band, not a point
Two candidates can be separated by a price, or not separated by any price the data supports. select() reports which case it is in, and only picks for you in the first.
band["members"] are the candidates that some price in Λ would select, where Λ is the derived rate interval by default. A band of one means the derived price settles the answer: winner is then the sigma argmax, exactly as before. A band of more than one means no price in that interval separates its members, and the tie is broken on worst-case regret,
regret(i) = max over lambda in Lambda of [ best sigma at lambda - sigma(i) at lambda ] reported per candidate in ranking["regret_sup"], in nats — the excess effective error that choosing i costs at the least favourable price in Λ. This is the only case in which the winner differs from the old single pick, and it is the case in which the old single pick was arbitrary: the previous version printed ! NOT ROBUST and named the other winners without choosing between them.
band["supported_span"] is reported whatever Λ is: the span of the envelope's own breakpoints, outside which no price changes the answer at all. A candidate outside it is optimal at no price, which is a proof, not missing evidence.
Because the derived price always lies inside Λ, the candidate it selects is always in the band, so minimax["regret_nats"] <= minimax["point_regret_nats"] always holds. rank and score are untouched by any of this: they order by sigma at the derived price, so score stays comparable across runs.
Three accuracies, four accuracies
Two readings need no fit, no bootstrap and no floor. Both are always reported, in jet and rung.
The jet — the price the frontier quotes. With S = -ln eps against x = ln resource, a triple gives the slope s, the curvature kappa and the channel count N_eff = s^2 / kappa. The canonical price is lambda* = s / sqrt(t * N_eff), so at the operating rule N_eff = 1 in delivered units it is simply
lambda* = s a first difference: no floor, no units, no origin, and the spacing cancels identically. N_eff itself is a ratio of second differences and is noise-dominated on published windows, so it is reported as a measurement standard; where no triple reads near the right angle the quote is the median over the readable triples, with the spread in jet["lambda_low" / "lambda_high"].
The jet replaces the fitted alpha/2 price in one situation only: the floor test could not be run (too few points, or a knee outside the measured range) and the marginal curve carries at least two readable triples. Where the floor is confirmed, alpha/2 and its bootstrap stand and those runs are unchanged number for number. Where the floor is rejected, nothing changes either: a scale-free frontier has no rate to quote and kappa = 0 makes N_eff meaningless. And on a single triple nothing changes, because one first difference is a quote with nothing to check it against — no better founded than an exponent interpolated through three points, so there is no reason to prefer it. Pass jet_price=False (--no-jet) to keep alpha/2 everywhere.
The rung — the third-order test, repaired. On a quadruple, with dd_k the Newton divided differences of S,
D1_hat = (3/2) * dd1 * dd3 / dd2^2 - 1 >= 0 is the hypothesis's own first rung, N_eff_dot = 0, is only N_eff_dot <= 2 — twice as loose as the hypothesis it is quoted against — so the sharper test comes free from the same four accuracies. And since a floor is present exactly when D1 < 1, the same reading carries rung["floor_sign"], a floor verdict with no fit behind it. rung["spacing_ratio"] is the widest-to-narrowest gap of the four nodes: node irregularity alone can flip a negative sign, so distrust a refutation when it is large.
How many models are needed
Counts refer to candidates that survive the cull, not those supplied.
Fewer still ranks usefully: the exponent's precision is flat from three to ten candidates when a floor is present, and price_free dominations hold at any price. On MAI 2021, three surviving candidates of ten recovered the official top two and identified six of the nine entries as dominated.
Competition leaderboards rarely reach eight by construction: their rules fix quality at a threshold and compete on cost, so the surviving frontier is short and carries little curvature. On a three-point frontier the price is not rescuable from either side — a three-parameter fit through three points has no residual left, and a single triple gives one first difference with nothing to check it against — so the price stays alpha/2, the verdict stays UNVERIFIED, and what these tables do get is the envelope, the band and the reported jet. Four or more points on the marginal curve is where the rung reads and the jet prices.
Ranked by the accuracy–time trade-off, no weight to choose. Any bare argument containing a comma is a candidate: name,accuracy,p1[,p2,...].
MAI 2026 INT8, SSIM vs inference time ms (NPU) — arXiv:2611.00963
python -m ab.nn.select --rank koreatechV2,0.8499,4.35 Godzilla,0.8831,215160 AntSR,0.8731,4.52 LoongSR,0.8586,5729 IN2GM,0.8701,46.5 z6,0.8699,5.49 AIO_MAI,0.8634,41.1 AntYSP,0.8729,4.33 MAI 2026 INT8, PSNR converted to (0,1) vs 3 resources — NPU ms, CPU ms, model size (KB) — arXiv:2611.00963
python -m ab.nn.select --rank B7,0.843000000,37,66 B0,0.771000000,0.39,5.3 B4,0.829000000,4.2,19 B6,0.840000000,19,43 B2,0.801000000,1,9.2 B1,0.791000000,0.7,7.8 B3,0.816000000,1.8,12 B5,0.836000000,9.9,30 YOLO11, mAP vs 4 resources — T4 TensorRT10 ms, CPU ONNX ms, params (M), FLOPs (B) — Ultralytics YOLO11 docs
python -m ab.nn.select --rank YOLO11l,0.534000000,6.2,238.6,25.3,87.2 YOLO11m,0.515000000,4.7,183.2,20.1,68.1 YOLO11x,0.547000000,11.3,462.8,56.9,195.3 YOLO11n,0.395000000,1.5,56.1,2.6,6.5 YOLO11s,0.470000000,2.5,90.0,9.4,21.6 MAI 2021 camera scene detection, Top-1 vs A11 Bionic runtime — CVPRW 2021
python -m ab.nn.select --rank Airia-Det,0.9300,17.51 Sidiki,0.7800,1.74 ByteScene,0.9500,4.44 MobileNet-V2,0.9417,16.38 PyImageSearch,0.8967,45.88 ALONG,0.9467,64.45 neptuneai,0.8367,4.17 EVAI,0.9300,3.35 DataArt,0.9150,54.13 Team-Horizon,0.9233,7.7 A CSV works too, with headers guessed or named:
python -m ab.nn.select models.csv --rank --acc-col top1 --res-col latency_ms --res-col params_M Other options
Exit codes: 0 clean, 1 UNVERIFIED or UNUSABLE, 2 bad input.
Scale: thousands of candidates are fine — they collapse to a frontier of a few hundred, and the fit runs on that. 20,000 models rank in about 1 second. The jet and the rung are O(n) in the frontier's length and the regret is one K-by-grid maximum on the matrix the rank spread already builds, so none of them is measurable in the total; on the runs where the jet supplies the price, 400 bootstrap refits are skipped and the call gets faster.
If you find the NN-Rank project to be useful for your research, please consider citing the articles Frontier-Based AI Model Selection and Multiresource Frontier:
@article{ABrain.Rank, author = {Ignatov, Dmitry}, title = {A Frontier-Based Theory of Quality--Resource Trade-offs for {AI} Model Selection}, journal = {SSRN}, volume = {7683960}, url = {https://doi.org/10.2139/ssrn.7683960}, year={2026} note = {Software: \url{https://github.com/ABrain-One/nn-rank}} } @article{ABrain.Multi-Rank, author = {Ignatov, Dmitry}, title = {A Differential Theory of Quality–Resource Trade-offs for {AI} Model Selection: The Multiresource Frontier and Its Minimax Price}, journal = {arXiv preprint}, volume = {arXiv:2611.23324}, url = {https://arxiv.org/abs/2611.23324}, year = {2026}, note = {Software: \url{https://github.com/ABrain-One/nn-rank}} } Project links
Apache-2.0 View SPDX License List
neural network ranking model selection AI system accuracy latency trade-off pareto front quality resource trade-off inference cost analysis model efficiency benchmark deep learning model comparison python model ranking minimax regret model selection under price uncertainty
Intended Audience Developers
Operating System OS Independent
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
Scientific/Engineering :: Information Analysis
Software Development :: Libraries
Release files for ai-rank 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 30.8 kB
Release files / ai_rank-1.0.2.tar.gz
Release files / ai_rank-1.0.2-py3-none-any.whl
Security for ai-rank 1.0.2
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 20, 2026 2 release files No provenance
Nov 19, 2026 2 release files No provenance
Nov 12, 2026 2 release files No provenance
Nov 9, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




