Skip to main content

A small framework for benchmarking machine learning models.

Project description

nnbench: A small framework for benchmarking machine learning models

Welcome to nnbench, a framework for benchmarking machine learning models. The main goals of this project are

  1. To provide a portable, easy-to-use solution for model evaluation that leads to better ML experiment organization, and
  2. To integrate with experiment and metadata tracking solutions for easy adoption.

On a high level, you can think of nnbench as "pytest for ML models" - you define benchmarks similarly to test cases, collect them, and selectively run them based on model type, markers, and environment info.

What's new is that upon completion, you can stream the resulting data to any sink of your choice (including multiple at the same), which allows easy integration with experiment trackers and metadata stores.

See the quickstart for a lightning-quick demo, or the examples for more advanced usages.

Installation

⚠️ nnbench is an experimental project - expect bugs and sharp edges.

Install it directly from source, for example either using pip or poetry:

pip install nnbench
# or
poetry add nnbench

A ⚡️- quick demo

To understand how nnbench works, you can run the following in your Python interpreter:

# example.py
import nnbench


@nnbench.benchmark
def product(a: int, b: int) -> int:
    return a * b


@nnbench.benchmark
def power(a: int, b: int) -> int:
    return a ** b


runner = nnbench.BenchmarkRunner()
reporter = nnbench.ConsoleReporter()
# run the above benchmarks with the parameters `a=2, b=10`...
record = runner.run("__main__", params={"a": 2, "b": 10})
reporter.display(record)  # ...and print the results to the terminal.

# results in a table look like the following:
# ┏━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
# ┃ Benchmark ┃ Value ┃ Wall time (ns) ┃ Parameters        ┃
# ┡━━━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
# │ product   │ 20    │ 1917           │ {'a': 2, 'b': 10} │
# │ power     │ 1024  │ 583            │ {'a': 2, 'b': 10} │
# └───────────┴───────┴────────────────┴───────────────────┘

Watch the following video for a high level overview of the capabilities and inner workings of nnbench.

nnbench overview video thumbnail

For a more realistic example of how to evaluate a trained model with a benchmark suite, check the Quickstart. For even more advanced usages of the library, you can check out the Examples in the documentation.

Contributing

We encourage and welcome contributions from the community to enhance the project. Please check discussions or raise an issue on GitHub for any problems you encounter with the library.

For information on the general development workflow, see the contribution guide.

License

The nnbench library is distributed under the Apache-2 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nnbench-0.4.0.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

nnbench-0.4.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file nnbench-0.4.0.tar.gz.

File metadata

  • Download URL: nnbench-0.4.0.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nnbench-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ce634b27d03bca1629ffd7bf4600a5bb4d521a1e41c16e4f5bb6c5c40ad83549
MD5 8a50cdeda101e360bd077aa365b09fea
BLAKE2b-256 e1a611a6e8dcd8b38ed680717723d4f2dfdabb93f970ec2a55aae6f086bf6c27

See more details on using hashes here.

Provenance

The following attestation bundles were made for nnbench-0.4.0.tar.gz:

Publisher: release.yaml on aai-institute/nnbench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nnbench-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: nnbench-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nnbench-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3428a77f358bf79e9fc710b6057b731e1cbc4fe53c9b15cc35c49aa7a52d0619
MD5 19aa4542a9bd4ff8500baa81aa16b978
BLAKE2b-256 7c490b5ac51fec6024c1ac1990cc85019865f96173c425fb27ea251dd4ea68fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for nnbench-0.4.0-py3-none-any.whl:

Publisher: release.yaml on aai-institute/nnbench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page