Branch summaries

What a branch passes to its parent, and why learned reduction keeps evidence a plain average loses.

A trxns branch can contain many field vectors from earlier payments and the latest payment. Reduction determines how much of that encoded collection reaches the parent. It follows the field interactions within the branch.

This explanation follows the reduction implementation introduced in 0.2.4, with the count lane added to learned queries in 0.3.5 and to rf.Mean() in 0.3.6. Both lanes scale the present-token count by the branch’s embedded leaves, so extending a model with another hidden target does not rescale existing predictions. The current pages are checked against RelFlow 0.3.6 (pinned source).

Choose what reaches the parent

Reduction Context passed to the parent Main tradeoff
rf.Attention(n_outputs=K) K learned summary vectors Learns which evidence to collect into a limited context.
rf.Mean() One average of present token vectors plus a count lane Simple; one learned direction carries how many tokens were present.
None The encoded token sequence Retains more detail and increases the parent’s token count.

Three lanes start from N encoded transaction tokens. The Attention lane passes them through K learned queries with additive sum and count lanes to K summaries. The Mean lane averages present tokens, adds a count lane, and sends one summary. The None lane passes all N routed slots to the parent.

Three lanes start from N encoded transaction tokens. The Attention lane passes them through K learned queries with additive sum and count lanes to K summaries. The Mean lane averages present tokens, adds a count lane, and sends one summary. The None lane passes all N routed slots to the parent.

Figure 1: Three reductions of the same encoded transactions. Attention and Mean send a fixed number of summaries; pass-through sends every slot.

These choices concern reduction. A mean reduction can still follow a learned branch encoder. Configure the branch’s attention separately; see the Branch reference.

Learned attention starts with trainable query vectors. Each query attends to the branch’s present memory and collects a summary. Multiple outputs provide multiple learned views of the same history; their meanings emerge during training.

Why an average loses multiplicity

An attention head combines values with normalized weights:

\[ s = \sum_i \alpha_i v_i, \qquad \sum_i \alpha_i = 1. \]

If every value vector is the same vector \(v\), this expression returns \(v\) whether the memory contains one copy or many. A plain mean has the same limitation, which is why both RelFlow reductions add a count lane: a learned direction scaled by the number of present tokens over the branch capacity, starting at zero so an untrained reduction is still the plain average. This is a statement about that normalized combination of identical values. Other parts of a network, including positional signals and earlier encoder updates, can supply information about sequence length.

At a common account-review cutoff, multiplicity may matter: several retained payments can carry different evidence from one payment even when their merchants and amounts are identical. RelFlow’s learned branch reduction includes additive evidence alongside attention.

Additive evidence

The learned reduction adds two trainable contributions to each normalized attention summary:

  • A projection of the sum of present branch input vectors, scaled by the square root of the configured capacity.
  • A learned direction scaled by the number of present tokens divided by that capacity.

Both contributions start at zero, so training decides how much to use them. The branch provides the additive evidence from its tokens before the sequence encoder; these tokens already include any coordinate attention. Absent tokens contribute neither values nor counts.

The count here is a token count. Fields can supply several tokens, and nested branch outputs can add further tokens. It is not directly a count of transactions or a sum of payment amounts. The model must learn how those vector and count signals relate to each transaction’s dispute target.

This mechanism supplies information that a normalized average can discard. It does not make the model an exact calculator or guarantee extrapolation to longer histories. Use the canonical proofs to inspect recorded evidence, and validate the reduction choice on the application’s held-out observations.

Next, follow the summaries through Tree routing and decoding.