Skip to main content

relflow

relflow builds PyTorch/Lightning models from nested records. Typed fields represent values; branches combine them into local contexts; decoders learn to predict selected fields from the available context.

Install

Python 3.12 or newer:

uv add relflow

Add relflow[text] for Hugging Face text encoders or relflow[serving] for the HTTP runtime.

Describe One Record

line_items:
  - sku: A12
    quantity: 2
    price: 19.99
  - sku: B07
    quantity: 1
    price: 45.50
returned: false

YAML makes the shape visible. Applications supply Arrow tables or eager Polars DataFrames with this structure.

import relflow as rf

model = rf.Model(
    name="order",
    d_model=64,
    n_layers=2,
    n_heads=4,
    batch_size=128,
    line_items=rf.Branch(
        length=32,
        sku=rf.Category(size=4096),
        quantity=rf.Number,
        price=rf.Number,
    ),
    returned=rf.Boolean(mask=True),
)

Parent keywords name each field. mask=True makes returned a supervised target whose value never enters the encoder. The branch builds line-item context before its reduced representation reaches the order root.

Train And Predict

train_table, validation_table, and request_table below are application-supplied Arrow tables. Prediction requests omit returned.

import lightning.pytorch as lit

model.optimizer = rf.adamw(learning_rate=1e-3)
data = rf.ArrowDataModule(
    model=model, train=train_table, validate=validation_table
)
trainer = lit.Trainer(max_epochs=30)
trainer.fit(model=model, datamodule=data)
predictions = model.predict(request_table)

For eager Polars DataFrames, use rf.PolarsDataModule with the same split arguments. predict returns an Arrow table; decoded results live under its predictions column at addresses such as order/returned.

Documentation

Docs use static examples and Typst model diagrams. Build them with make render; run make check-docs to validate the render in a temporary directory. Package checks use uv run pytest; synthetic learning checks use make proofs. See CONTRIBUTING.md for development conventions.

Community · Apache 2.0 license

Download files

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

Source Distribution

relflow-0.2.2.tar.gz (172.6 kB view details)

Uploaded Source

Built Distribution

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

relflow-0.2.2-py3-none-any.whl (196.0 kB view details)

Uploaded Python 3

File details

Details for the file relflow-0.2.2.tar.gz.

File metadata

  • Download URL: relflow-0.2.2.tar.gz
  • Upload date:
  • Size: 172.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for relflow-0.2.2.tar.gz
Algorithm Hash digest
SHA256 50f6d20015b7f4569f736b3efd5a457923a77c2cfd63c3c86ff90f7ed12eb940
MD5 bd8965ea0f56cb1abc4a7e95fb6a78f8
BLAKE2b-256 7f9755c6688b8ecf110aa08e24ed1e87499aef64e5b0f830ceac576f57bde47f

See more details on using hashes here.

Provenance

The following attestation bundles were made for relflow-0.2.2.tar.gz:

Publisher: release.yml on relflow/relflow

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

File details

Details for the file relflow-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: relflow-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 196.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for relflow-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 068d8977914a551c4a168fa150e093fefb580067039cd73ba0c4ae02225591a5
MD5 51fc1bd90b8ad32dc7fcb37ba1127dd8
BLAKE2b-256 5557154f41da5cc43412e07927ba757195a746a5d52fe4852676160410905363

See more details on using hashes here.

Provenance

The following attestation bundles were made for relflow-0.2.2-py3-none-any.whl:

Publisher: release.yml on relflow/relflow

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

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page