Binding Data

A model reads one observation at a time. Field names follow the record’s nesting; branches describe repeated objects. Extra source columns are available to preprocessors and retention without becoming model inputs.

One order:

request_id: order-42
amount: 86.50
items:
  - sku: coat-17
    quantity: 1
  - sku: scarf-03
    quantity: 2
returned: false
import relflow as rf

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

amount reads the top-level field. items selects the collection, and its children read each item’s sku and quantity. The parent keywords supply the names. returned supplies a training target; mask=True keeps its value out of the encoded context.

Order root with amount input, a repeated items branch containing SKU and quantity inputs, and returned prediction target.

Order root with amount input, a repeated items branch containing SKU and quantity inputs, and returned prediction target.

Figure 1: The items branch builds context from product and quantity fields; the order uses this context and its amount to predict a return.

Missing required fields are binding errors. Explicit nulls follow the field’s nullable contract. See Query Paths when names or nesting differ.

Use a preprocessor when the source needs renaming, derived values, filtering, joins, or reshaping before binding. Its output defines the records the model reads. The guide shows how to reshape nested account data into a shared repeated branch and reuse that preparation for training and prediction.