How Fields Interact
A payment’s amount has more meaning alongside its merchant and the account’s earlier activity. RelFlow builds that context at two scales: fields belonging to one event record, then events belonging to the same history. This keeps the relationship between an amount and its merchant available when the model compares transactions. Start with transaction history for the application example.
This explanation was checked against the 0.2.4 branch encoder.
Within One Transaction
Follow the tutorial’s collection. The current payment is the final transaction; the earlier transactions were known at its decision time:
trxns:
- booked_at: "2026-05-21T10:00:00"
amount: 32.00
merchant: Station Cafe
disputed: false
- booked_at: "2026-05-27T18:15:00"
amount: 56.20
merchant: North Market
disputed: true
- booked_at: "2026-05-28T14:30:00"
amount: 84.50
merchant: North Market
disputed: falseEach field first supplies an embedding at each transaction coordinate. Coordinate attention groups the direct sibling fields at the same coordinate: booked_at, amount, and merchant from the first transaction interact with one another. The other transactions have their own groups. This step allows an amount’s representation to depend on the merchant attached to that amount.
disputed=rf.Boolean(mask=True) keeps every dispute label out of the inputs and supervises every retained transaction. Each label means a new dispute during the 30 days after the common review cutoff, 2026-05-28T14:30:00. The application attaches these Boolean answers after that window is complete; they are not facts available to the model at review.
Two histories can have the same total spend and merchant counts while pairing the larger purchase with different merchants. Keeping each transaction’s fields together preserves that distinction as evidence for learning.
The coordinate encoder operates on active direct leaf fields. A nested branch contributes its own representation later; it does not join this group of direct fields. When fewer than two active direct fields are available, there is no coordinate interaction to perform. Setting branch attention to None also disables this encoder.
Across The History
After coordinate attention, the branch concatenates its children’s tokens into one sequence and applies its sequence encoder. Tokens from different history positions can now interact. Across a longer history, the model can learn patterns such as repeated purchases at one merchant, changing amounts, or activity concentrated in a short period. Whether these patterns help predict a dispute must be checked on held-out payments.
These two stages answer different questions:
| Stage | Available context | Example relationship |
|---|---|---|
| Coordinate attention | Direct fields of one transaction | Which merchant received this amount? |
| Sequence attention | Present child tokens across the branch | How does this transaction compare with earlier ones? |
| Branch reduction | The branch’s encoded transactions | Which context should reach the observation root? |
Reduction is a separate step, described in Branch Summaries. With the default reduction, trxns passes a learned summary to its parent. That summary includes the earlier and latest transactions; the root has no duplicate amount or merchant fields. The summary is trained for the model’s objectives; it is not a readable transaction ledger or a guaranteed calculation of a business statistic.
Presence And Position
Padding represents an absent coordinate. The encoder excludes it from attention and restores zero output at absent positions. A null value at a present coordinate has its own field state; replacing it with zero changes what the model observes. See field states.
Rotary position information gives attention a signal about token positions. booked_at=rf.DateParts(dateparts=["day_of_month", "day_of_week", "hour_of_day"]) supplies calendar cycles. Those cycles do not compute elapsed time or preserve every distinction in the original timestamp. Input ordering still belongs to the application: sort by the full booking timestamp, oldest to newest, and keep only transactions available through the latest payment’s decision time. Position information does not repair an incorrectly ordered collection or prevent future information from entering the inputs.
Sequence attention can use the complete retained collection. All predictions in this example share the same review cutoff and future outcome window. They are not forecasts made separately at each transaction’s original booking time.
Encoder updates use residual attention and feed-forward blocks with RMSNorm and tanh GELU, as defined in the reviewed neural blocks. Architecture options and collection limits belong in the model tree and Branch reference.