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-ml

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.1.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.1-py3-none-any.whl (78.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yab_ml-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9cffd3c067c3da89538b63fd0eea1f4e80684093b17515b3d71d62fb670e7a18
MD5 0a9c14ac0b7146321a9b434554802123
BLAKE2b-256 46e9c6aa542a86ccd9e08ea195c702e3f42738c3c6849e6ed37d9b2e4c194c82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yab_ml-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7cd223e4af84dfeb86b89881a91f710dca5f8b33f8e7bde9eea427f8134c2f9
MD5 213b91bac9203ffa8eb48dcea7d95ac6
BLAKE2b-256 ee18b9aaa0f3b9856c5a2e244e87a09830d2f5c2cf56a961945a764d5eab0666

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