Recover grouped deviations from one learned collection summary plus aligned item context.
This repeats grouped peer deviation with one learned branch output. The shared summary carries collection context while each target still receives its own visible group and value as query context.
Seed 3720 on gpu: 6 of 6 behavioral checks met. See the measurements below.
Insights
A single collection summary can support per-item predictions when the decoder also sees each item’s group and value. The result is not evidence that one vector losslessly stores an arbitrary collection or that all useful information passes through that vector alone.
Corrupting group labels while retaining original targets removes accuracy, supporting use of the membership relationship in this compressed route. Translation and permutation controls from the retained-token case have not been repeated here. This model also trains for more steps than that case, so the recorded accuracy comparison is not an efficiency comparison. Validate summary capacity for the actual target and collection sizes before generalizing from these three two-member groups.
Setup
Code
"""Infer grouped deviations using one learned collection summary.Each repeated target still receives its aligned visible group and value asquery context. The shared summary supplies peer context; this is not a claimthat one vector losslessly preserves every collection. Rotated labels testwhether the model uses the original peer memberships.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 ="P033"ITEMS =6GROUPS = ("A", "B", "C")
The means are now A: 0, B: 2, and C: −1.5. These are correctly labeled examples of the same task with a smaller within-group spread. The single summary must support these changed targets alongside each item’s local context.
The first example’s labels rotate by one position, but values and deviation targets stay fixed. The targets therefore no longer describe the visible grouping. The retained corruption control checks that this change removes accuracy; it does not require reproducing those now-inconsistent targets.
Synthetic data and controls
Code
def records(*, rows: int, seed: int) -> Iterator[dict]:"""Generate randomly interleaved, exactly centered two-member groups.""" rng = np.random.default_rng(seed)for _ inrange(rows): items: list[dict[str, object]] = []for group in GROUPS: mean =float(rng.uniform(-3.5, 3.5)) deviation =float(rng.uniform(0.2, 1.2))for signed in (-deviation, deviation): item: dict[str, object] = {"group": group, "value": mean + signed, "deviation": signed} items.append(item) order = rng.permutation(ITEMS)yield {"items": [items[index] for index in order]}def targets(rows: list[dict]) -> np.ndarray:return np.asarray([item["deviation"] for row in rows for item in row["items"]])def predict(model: rf.Model, rows: list[dict]) -> np.ndarray: inputs = [ {"items": [{key: value for key, value in item.items() if key !="deviation"} for item in row["items"]]}for row in rows ] output = model.predict(inputs).to_pylist()return np.asarray( [value["content"] for row in output for value in row["predictions"]["collection/items/deviation"]] )def rmse(actual: np.ndarray, predicted: np.ndarray |float) ->float:returnfloat(np.sqrt(np.mean(np.square(actual - predicted))))def corrupt_groups(rows: list[dict]) ->list[dict]:"""Rotate only labels, preserving all values, targets, and label counts.""" result = []for row in rows: labels = [item["group"] for item in row["items"]] shifted = labels[1:] + labels[:1] result.append({"items": [{**item, "group": label} for item, label inzip(row["items"], shifted, strict=True)]})return resultdef implied_deviation(rows: list[dict]) -> np.ndarray:"""Measure how strongly changed peer memberships alter the correct answer.""" values = []for row in rows: means = { group: float(np.mean([item["value"] for item in row["items"] if item["group"] == group]))for group in GROUPS } values.extend(item["value"] - means[item["group"]] for item in row["items"])return np.asarray(values)
Model tree
Figure 1: One learned item summary supplies shared context, while each target retains its aligned visible group and value. The root keeps its routed tokens.
The branch uses rf.Attention(n_outputs=1, n_layers=2) and the root uses reduction=None. The tree matches the retained-token case; the reduction route is the difference.
How it works
Coordinate-local encoding first mixes each item’s group and value. A learned summary can then retain peer context used by separate, coordinate-conditioned target queries. Label corruption changes peer membership while retaining the original targets and the value and label marginals. The resulting loss of accuracy tests whether that membership survived in the information available to the decoder.
Repeat seed calibration and add translation and complete-item permutation controls to this compressed case. Sweep group sizes, simultaneous targets, and summary width before generalizing its capacity. A smaller representation alone does not establish a speed or memory improvement.
Reproduce
Run by stable ID from the repository root:
uv run python proofs/run.py P033
Or run the self-contained script directly:
PYTHONPATH=proofs uv run python proofs/relational/single_query_preserves_group_membership.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.