Skip to main content

YAB

License: MIT Python GitHub stars GitHub forks

Yet Another Boilerplate

YAB is a Python library that removes repetitive PyTorch boilerplate without taking away control.

It provides two primary workflows:

  • yab.use() renders a template in memory and returns a handle to the generated implementation.
  • yab.write() injects clean, editable PyTorch code directly into your Python script or Jupyter notebook.

Unlike frameworks that hide everything behind custom APIs, YAB generates real code that belongs to you.


Features

  • Zero-boilerplate PyTorch workflows
  • Editable generated source code
  • Three abstraction levels
  • Python API and CLI
  • AST-based code injection
  • Jupyter notebook support
  • Lazy dataset loading
  • Built-in fallback datasets
  • Automatic formatting with Black and Ruff
  • Versioned templates
  • Extensible template registry
  • Idempotent code generation

Installation

pip install yab

Quick Start

Return a template handle

import yab

handle = yab.use(
    "tabular_classifier",
    type="full",
    input_features=4,
    num_classes=3,
)

trainer = handle.get_trainer()
trainer.fit()

Nothing is written to disk.


Generate boilerplate

import yab

yab.write(
    "tabular_classifier",
    type="full",
    input_features=4,
    num_classes=3,
)

Repeated calls update the previously generated YAB block instead of creating duplicates.


Lazy Dataset Loading

Generated templates do not construct datasets during import.

yab.use() renders the template, handle.get_trainer() constructs the trainer, and trainer.fit() loads either your own dataset via data_path or a built-in fallback dataset.

Supported built-in datasets include:

  • Iris
  • Wine
  • MNIST
  • CIFAR-10
  • AG News
  • IMDB

Abstraction Levels

Full

Returns a TemplateHandle exposing get_trainer().

handle = yab.use("tabular_classifier", type="full")
trainer = handle.get_trainer()
trainer.fit()

Partial

Returns (model, handle).

model, handle = yab.use("tabular_classifier", type="partial")
trainer = handle.get_trainer()
trainer.fit()

Raw

Returns only the generated model.

model = yab.use("tabular_classifier", type="raw")

CLI

yab list
yab types
yab use tabular_classifier --type full
yab write tabular_classifier --type partial
yab version

Templates

Implemented

  • Tabular Classifier
  • Image Classifier
  • Text Classifier

Planned

  • Autoencoder
  • GAN
  • Transformer Fine-Tuning

Testing

Coverage includes:

  • Template rendering
  • AST injection
  • Notebook injection
  • Duplicate detection
  • Formatting
  • End-to-end model training
  • CLI behavior
  • Built-in fallback datasets

Continuous Integration

Every push runs:

  • Ruff
  • Black
  • Pytest

Tagged releases can be published to PyPI.


Philosophy

Most libraries replace boilerplate with another abstraction.

YAB replaces boilerplate with your own code.

You keep complete ownership of what is generated while avoiding hours of repetitive setup.


License

MIT

Download files

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

Source Distribution

yab_ml-0.1.0.tar.gz (48.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yab_ml-0.1.0-py3-none-any.whl (78.5 kB view details)

Uploaded Python 3

File details

Details for the file yab_ml-0.1.0.tar.gz.

File metadata

  • Download URL: yab_ml-0.1.0.tar.gz
  • Upload date:
  • Size: 48.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for yab_ml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e9d8b8fe3785fc5ef884438bb0823fe2141aa0072ab14b05a83c51be84f74e3
MD5 0b77d52aa7df1684725efe6ef591e1d6
BLAKE2b-256 767f9b7defba68a9feef56616674b13b083998ebb45317ab5d7b5c748a7282e6

See more details on using hashes here.

File details

Details for the file yab_ml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yab_ml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 78.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for yab_ml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48cd3bee5528ad0b8db82149b3f7289e75b00039e6617349faa01989fbc5ed47
MD5 73c4ea051bd0c5eb485ce46d01500f33
BLAKE2b-256 1a4756ad55b099373d4fbff6042a6c477cf6318e40e3d56bbee0d08794f2b562

See more details on using hashes here.

Supported by

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