Relational Transformers Utils
Utility tooling that wires Relational Transformers
into a working product: context collection, normalization, ablation measurement,
metrics, and checkpoint quantization. A second package, relben, holds RelBench
benchmark utilities. Everything is pure Python over numpy and torch.
Applications own retrieval and encoding. This package covers the numeric steps between
retrieved rows and a RelationalBatch, and the measurement steps after a prediction
comes back. It contains no query language, no connectors, and no context-builder
pipeline.
Installation
pip install -U relational-transformers-utils
What's Inside
Context collection (csc)
CscAdjacency is a compressed-sparse-column adjacency over foreign-key edges. Build it
once from edge arrays, then answer time-bounded "latest children at or before this
anchor" queries with one binary search each. CscIndex wraps a whole schema of
caller-provided rows behind the same idea. Tie handling matches the RT-J reference
byte for byte.
from relational_transformers_utils import CscIndex, TemporalBound
index = CscIndex.build(schema, {"customers": customer_rows, "orders": order_rows})
recent_orders = index.children(link, customer_id, TemporalBound.at_or_before(anchor), 16)
Normalization
ColumnStats fits per-column mean/std for numeric cells and one global normalizer for
datetimes, with the reference preprocessor's exact conventions: sample std for columns,
population std for datetimes, and 1.0 in place of a zero std. normalize_sequence
turns one context's raw scalar cells into model-ready floats in zero-shot or reference
mode, and bf16_as_f32 reproduces the bfloat16 storage boundary.
from relational_transformers_utils import ColumnStats, normalize_sequence
stats = ColumnStats.fit(schema, tables, bound=training_bound)
values = normalize_sequence(columns, sem_types, raw_values, is_target,
mode="reference", column_stats=stats)
Ablation
AblationEvaluator measures how much named groups of cells move a model's predictions
across a dataset, through RelationalBatch.ablate and identity-activation scores.
from relational_transformers_utils import AblationEvaluator
metrics = AblationEvaluator(examples, {"support": [11, 12]})(model)
Metrics
Pure-numpy AUROC with tie-corrected rank sums, accuracy, Brier score, clamped log loss,
bootstrap AUROC intervals, MAE, R², and a direction-aware better() comparator for
model selection.
Quantizers
rt-quantize converts an RT-J checkpoint to FP8, row-wise int8, or packed int4. Every
output loads through the standard relational-transformers constructor.
rt-quantize RelativeDB/rt-j-fp16 ./rt-j-int8 --format int8
Benchmarks (relben)
The curated 21-task RelBench catalog, keyed submission-CSV writers, atomic run records, score-matrix reports with gain-versus-baseline tables, and hurdle-gate tuning for zero-inflated regression targets.
from relben import select_tasks, write_submission
for task in select_tasks(["rel-f1"]):
write_submission(out / task.filename, task.target, predictions[task.id])
Development
python -m pip install -e '.[dev]'
pytest
License
Apache License 2.0.
Release files for relational-transformers-utils 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| relational_transformers_utils-0.1.0.tar.gz | 64.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| relational_transformers_utils-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 121.8 kB
Release files / relational_transformers_utils-0.1.0.tar.gz
| Download URL | relational_transformers_utils-0.1.0.tar.gz |
|---|---|
| Size | 64.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dcc5f84bb5f9b46b21dde51080b7c9db499d00f75ee07e70d24f718c3020be2a
|
|
BLAKE2b-256 checksum How to use checksums |
092013e86e5ead40cae2835e805fc05950c53c68e828ee803248eb458c9dda25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 5, 2026.
Transparency logRelease files / relational_transformers_utils-0.1.0-py3-none-any.whl
| Download URL | relational_transformers_utils-0.1.0-py3-none-any.whl |
|---|---|
| Size | 57.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
974da7e2bf95edebac92d6585867befbe00f1c6c239bdf95c69688833f3c3a52
|
|
BLAKE2b-256 checksum How to use checksums |
8b871c7d884516c8af4a9d129ea56e315bcc9210bccddb453cfeb95617d2f894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 5, 2026.
Transparency log