Hash

Use Hash when equality between identifiers matters, but their identities should not become a learned vocabulary. Use Category for bounded labels whose individual meaning should persist across observations.

account_id: account-17
transfers:
  - counterparty_id: account-17
    amount: 42.75
  - counterparty_id: account-92
    amount: 16.00
fraud: false
import relflow as rf

model = rf.Model(
    d_model=64, n_layers=2, n_heads=4,
    account_id=rf.Hash(n_hashes=4),
    transfers=rf.Branch(
        length=32,
        reduction=None,
        counterparty_id=rf.Hash(n_hashes=4),
        amount=rf.Number,
    ),
    fraud=rf.Boolean(mask=True),
)

Input and options

Accepts scalar Arrow integers, strings, and binary values. Normalize other identifier types upstream. A null has its own state.

Option Default Meaning
n_hashes 1 Positive number of independent signed 64-bit fingerprint lanes.
n_bands 8 Positive lower exponent bound for Fourier features.
offset 4 Positive upper exponent bound for Fourier features.
n_buckets 4 Reconstruction classes per lane; must exceed one.

Equality and learning

Every Hash field shares a salt within one local-rank batch. Matching values of the same Arrow family and matching Hash configuration therefore have the same representation across fields. Training and validation draw a new salt per batch; test and prediction use zero. Hashes are not durable identifiers across library versions.

Hash lanes become Fourier features directly in model space; there is no learned content vocabulary or projection. Non-valued positions use state embeddings. Reconstruction predicts quantized hash lanes, with n_buckets ** n_hashes possible fingerprints, rather than recovering the original identifier.

Equal fingerprints provide an equality signal while the tokens remain together. They do not guarantee a join or item correspondence after branch reduction. The example uses reduction=None to keep transfer tokens available to the root; see Branch reduction.

Compare the unseen-identity equality proof with the sibling-collection overlap boundary. Their trees show why a working equality representation alone does not establish successful comparison across collections.

Output

Hash has no decoded public content. embed=True can export a contextual embedding, as described in shared leaf options. Keep IDs outside the model schema when equality itself is not useful.