Verify scalar unseen-Hash equality before asking the model to compare whole collections.
Two scalar Hash fields provide the smallest equality problem. This positive control asks whether previously unseen identities can be compared before introducing repeated branches and collection-level reasoning.
Seed 3701 on gpu: 4 of 4 behavioral checks met. See the measurements below.
Insights
The model can compare two unseen scalar identities, so failed collection overlap cannot be explained solely by an unusable Hash representation. The fields share the same root context and preserve equality through Hash encoding. Fresh identities and balanced labels rule out a persistent lookup table or a majority-label solution.
Making formerly equal pairs unequal while retaining their positive labels lowers their predicted probabilities and removes ranking skill against those labels. That supports sensitivity to equality, rather than merely a favorable intact score. It does not establish calibrated probabilities or an all-pairs comparison across repeated branches. Keep this primitive control when testing more complex identity-routing schemas, so different failure locations remain distinguishable.
Setup
Code
"""Learn equality between two scalar Hash fields with unseen identities.This control removes collection routing from the overlap problem. Break everypositive equality while retaining its label to verify that strong accuracycomes from equality rather than memorizing names or label proportions.Run this file with --help for seed, training-budget, and reporting options."""from __future__ import annotationsfrom collections.abc import Iteratorfrom functools import partialimport lightning.pytorch as litimport numpy as npimport torchfrom reporting import reportimport relflow as rfPROOF_ID ="P029"MIN_LENGTH =2MAX_LENGTH =5
Examples
Two matching identities
left_id: owlright_id: owlequal:true
equal is training supervision hidden by mask=True. Negative records have different left and right IDs. Identity namespaces are disjoint across splits.
Different identities
left_id: owlright_id: yakequal:false
The correct label is false because the keys differ. Positive and negative records have the same two-field schema and balanced frequencies.
Break equality while retaining the positive label
left_id: owlright_id: eelequal:true
This intervention starts from the matching pair and changes its right key. The control retains the original true label, although the visible keys are unequal. A model using equality should lower its positive probability. When all originally positive examples are broken this way, ranking against the retained labels should become chance-level.
Synthetic data and controls
Code
def records(*, rows: int, seed: int, namespace: str, break_equal: bool=False) -> Iterator[dict]:"""Generate the unseen-Hash equality control used to calibrate the primitive."""if rows <=0or rows %2:raiseValueError(f"pair rows must be a positive even integer, got {rows}") rng = np.random.default_rng(seed) labels = np.tile(np.asarray([False, True]), rows //2) rng.shuffle(labels)for row_index, equal inenumerate(labels): left =f"{namespace}-{row_index:06d}-left" right = left if equal and (not break_equal) elsef"{namespace}-{row_index:06d}-right"yield {"left_id": left, "right_id": right, "equal": bool(equal)}def auc(target: np.ndarray, predicted: np.ndarray) ->float:"""Compute binary ROC AUC from all positive/negative score pairs.""" positive = predicted[target] negative = predicted[~target]ifnotlen(positive) ornotlen(negative):raiseValueError("AUC requires at least one positive and one negative example") comparisons = positive[:, None] - negative[None, :]returnfloat((comparisons >0).mean() +0.5* (comparisons ==0).mean())def probabilities(model: rf.Model, rows: list[dict]) -> np.ndarray: output = model.predict(rows).to_pylist()return np.asarray([row["predictions"]["pair/equal"]["content"]["probability"] for row in output])
Model tree
Figure 1: Two scalar Hash inputs share a root with one learned attention summary and a masked Boolean equality target.
The root uses default attention reduction. No preprocessing feature supplies the equality result to the encoder.
How it works
Hash preserves equality within an encoded batch, allowing attention and the Boolean decoder to learn the relationship between two visible identities. The labels are balanced and each row uses fresh keys. The intervention makes all formerly equal pairs unequal while keeping their original labels, so positive probabilities should drop and ranking against those labels should return to chance.
Repeat the primitive control alongside the collection proof across the promotion seed matrix. Retain the broken-equality intervention when changing Hash configuration or testing more difficult schemas, so a collection failure can be distinguished from a failure of scalar identity comparison.
Reproduce
Run by stable ID from the repository root:
uv run python proofs/run.py P029
Or run the self-contained script directly:
PYTHONPATH=proofs uv run python proofs/relational/flat_unseen_hash_equality_control.py
Add --accelerator gpu for CUDA or --seed 42 for another seeded experiment. --steps 2 checks execution with a short training budget; it is recorded as a smoke run.