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()
# run the above benchmarks with the parameters `a=2, b=10`...
record = runner.run("__main__", params={"a": 2, "b": 10})
rep = nnbench.BenchmarkReporter()
rep.display(record)  # ...and print the results to the terminal.

# results in a table look like the following:
# name     function    date                 parameters         value    time_ns
# -------  ----------  -------------------  -----------------  -------  ---------
# product  product     2024-03-08T18:03:48  {'a': 2, 'b': 10}       20       1000
# power    power       2024-03-08T18:03:48  {'a': 2, 'b': 10}     1024        750

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.3.0.tar.gz (300.9 kB view details)

Uploaded Source

Built Distribution

nnbench-0.3.0-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nnbench-0.3.0.tar.gz
  • Upload date:
  • Size: 300.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nnbench-0.3.0.tar.gz
Algorithm Hash digest
SHA256 262117548d0931729678987fd4c722594c4a515c0ce5193908ed5551f3a2722c
MD5 e5fa066e947e782975b3e51afbf25a1e
BLAKE2b-256 f61553fd873a970e9b0fe4f13c7a0c36570bd93434dad756faa50422aeb35dc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nnbench-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nnbench-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed0e0f54f87eca1bd1ef1bafcc36e4acfec0a91332181feebcda379d162b12d7
MD5 7d8b3842d56a03752e3b5cbd460394e7
BLAKE2b-256 f42bbf014a208e1df795b672209e0c7b0c371daa6909f501f097c2a0b99b89a4

See more details on using hashes here.

Supported by

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