Predictive queries (RelQL) over your own data: GraphQL-style user-defined retrievers, no bundled database connectors.
Project description
RelativeDB / RelQL
RelativeDB is an optimized implementation of Relational Transformers, exposed through RelQL, a query language for predicting what happens next:
PREDICT NOT EXISTS(orders.*)
FROM customers
"For every customer, what is the probability they don't place an order."
RelativeDB works best with many tables (10–100) and needs no feature engineering. Subgraphs are discovered automatically, though you can ablate them to find what features really matter. Because it uses a pretrained model, it works in environments with very little data.
# Auto-label a GitHub issue: predict its label from title, body, and history.
PREDICT issues.label
WHERE issues.label IS NULL
# Would customer 42 churn if we moved them to the premium plan?
PREDICT NOT EXISTS(orders.*)
FROM customers c
WHERE c.customer_id = 42
ASSUMING c.plan = 'premium'
# Expected spend per customer over the next quarter.
PREDICT SUM(transactions.price) OVER (90 DAYS FOLLOWING)
FROM customers
# The 12 articles each customer is most likely to buy next.
PREDICT ARRAY_AGG(transactions.article_id) OVER (30 DAYS FOLLOWING RANK TOP 12)
FROM customers
Install
pip install relativedb
Wheels bundle the native inference engine for macOS arm64 (Apple
Silicon; CPU and Metal). On other platforms the package installs from
source; build the engine from
the repository (cpp/ with CMake)
and point RELATIVEDB_RT_LIB at the built librt_c.
Quickstart: 90-day churn from your own DataFrames
from relativedb import (Schema, TableDef, LinkDef, ValueType,
RetrieverWiring, Engine, ExecutionInput, RtNativeBackend)
schema = (Schema.new_schema()
.table(TableDef.new_table("customers")
.column("age", ValueType.NUMBER)
.column("signup_date", ValueType.DATETIME)
.primary_key("customer_id").build())
.table(TableDef.new_table("orders")
.column("qty", ValueType.NUMBER)
.column("order_date", ValueType.DATETIME)
.primary_key("order_id").time_column("order_date").build())
.link(LinkDef("orders", "customer_id", "customers"))
.build())
wiring = (RetrieverWiring.new_wiring()
.entities("customers", lambda table, ids, bound: customer_dao.by_ids(ids))
.entities("orders", lambda table, ids, bound: order_dao.by_ids(ids, bound))
.default_links(lambda link, parent_id, bound, limit:
order_dao.recent_by_customer(parent_id, bound.as_of, limit))
.build())
engine = Engine(schema, wiring, model_backend=RtNativeBackend(schema=schema))
result = engine.execute(ExecutionInput(
query="PREDICT NOT EXISTS(orders.*) OVER (90 DAYS FOLLOWING) FROM customers "
"WHERE customers.customer_id IN :ids",
params={"ids": ["C7"]}, # the cohort; drop the WHERE to score every customer
anchor_time=t0))
Checkpoints
Model checkpoints resolve through the Hugging Face cache on first use. Set
RELATIVEDB_RT_QUANTIZED to f16, q8, or q4 to trade footprint for
precision:
| Checkpoint | On-disk | Accuracy | Download |
|---|---|---|---|
| fp32 | 342 MB | reference | — |
| fp16 | 172 MB | identical | rt-j-fp16 |
| int8 | 88 MB | ±0.01 | rt-j-int8 |
| int4 | 64 MB | ±0.15 | rt-j-int4 |
The model
RelativeDB is based on:
- stanford-star/relational-transformer — RT-J: Large-Scale Pretraining of Relational Transformers for Context-Efficient Predictions
- Relational Transformer: Toward Zero-Shot Foundation Models for Relational Data (arXiv:2510.06377)
Docs
Read the RelQL book.
License
Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file relativedb-0.1.0.tar.gz.
File metadata
- Download URL: relativedb-0.1.0.tar.gz
- Upload date:
- Size: 103.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
655891990bb1d6599dbe5a9e90fc5b5dacd4d0219583ec71383a5b0cc0580a9d
|
|
| MD5 |
3f92f4c8fda49cc8f4333e26c371dc5b
|
|
| BLAKE2b-256 |
0b73329df07e433c04736de360c1c205bca8d74f95aedf4209a52036d2c26eaf
|
File details
Details for the file relativedb-0.1.0-py3-none-macosx_13_0_arm64.whl.
File metadata
- Download URL: relativedb-0.1.0-py3-none-macosx_13_0_arm64.whl
- Upload date:
- Size: 289.0 kB
- Tags: Python 3, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6c7ba09598cd32b493839652c5383144150aa14db3952f3f7d98d8e7b48008
|
|
| MD5 |
13101144d4d07ca02c419e43430f54bf
|
|
| BLAKE2b-256 |
0f9ba80738381d3c1825c0c8d271072da5af1f2ba9912478ef5a8ef79fabd5ce
|