Skip to content

feat(compare): Compare Representations tab (prototype) - #553

Draft
KartikP wants to merge 2 commits into
masterfrom
kp/compare-representations
Draft

KartikP wants to merge 2 commits into
masterfrom
kp/compare-representations

Conversation

@KartikP

@KartikP KartikP commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Draft — for looking at, not merging. Prototype of the activations subpage discussed for the compare page. Spec: tasks/activations-compare-spec.md.

What it shows

A third tab on the compare page: how similarly two models represent the same stimuli, independent of how they score. Computed from activations cached during scoring, so no model is re-run.

stimulus set n CKA layer
Ferguson2024_color 48 0.951 readout only
Ferguson2024_circle_line 48 0.922 readout only
Geirhos2021_uniform-noise 800 0.821 readout only
Geirhos2021_uniform-noise --target8.00--source3.00 800 0.461 readout only
Geirhos2021_stylized --target8.00--source3.00 800 0.435 readout only

The last two are the interesting rows: same stimuli, same models, differing only by place_on_screen rescaling. Agreement nearly halves, and effective dimensionality roughly doubles (13.8 → 28.1). That is invisible on a leaderboard.

The architectural decision

The site never reads the activation cache. Three measured reasons: entries reach 5 GB, the cache is a 365-day rolling window with a 7-day noncurrent sweep, and keys carry plugin SHAs so a plugin revision silently changes them. A precompute step writes small durable artifacts; the view reads only those.

Payload sizes: 1.2 KB for the table, 2.8 KB with embeddings. Embeddings are withheld unless a stimulus set is requested, since they dominate.

Artifacts sit behind _load_artifacts(), so the still-open S3-vs-DB question can be settled later without touching the view, route, or template. No migrations, no new tables.

Most currently-cached public stimulus sets are behavioural, so their cache entries hold only the classifier layer. CKA there is classifier agreement between two ImageNet models — near-tautological, and not representational similarity. Those rows are flagged readout only in the payload and tagged in the table. A test asserts the flag survives into the payload, because an unlabelled number here is a misleading one.

Region-layer coverage does exist (10 public shared sets including Li2026, Zerbe2026, Allen2022, Rust2012, Marques2020) — that analysis is still running and will replace the fixture.

Tests

8 tests, including that a missing or malformed artifact file yields an empty payload rather than a 500. The panel is additive; it must not be able to take the compare page down with it.

Known limits

  • 2 models, so the model↔model matrix is 2×2. It fills automatically as models are scored.
  • Fixture data, not live.
  • Embeddings are classical MDS from the same Gram matrix the artifact already stores — no extra dependency, no t-SNE hyperparameters to defend.

Model activations are now cached in S3 during scoring, which makes a
comparison cheap that previously required re-running both models: how
similarly two models represent the same stimuli, independent of score.

The view never reads the activation cache. Entries reach 5 GB, the cache is a
365-day rolling window, and keys carry plugin SHAs -- so a plugin revision
would silently change them and the page would 404 on its own data. A
precompute step writes small derived artifacts; this serves those. Artifacts
are a bundled fixture for now, behind _load_artifacts() so the S3-vs-DB
decision can change without touching view, route or template.

Sizes are the point: the browser gets 2D coordinates and scalars (1.2 KB for
the table, 2.8 KB with embeddings). The similarity matrices they derive from
stay server-side, and the activations themselves are never served.

Readout-only comparisons are flagged in the payload and labelled in the UI.
Most currently-cached public stimulus sets are behavioural, so their entries
hold only the classifier layer -- CKA there is classifier agreement, not
representational similarity, and an unlabelled number would mislead.

The two-way tab toggle is generalised to a registry; a third tab made the
boolean shape untenable.

Prototype, not production: 2 models, 5 stimulus sets, fixture data.
Replaces the readout-only fixture with region-layer results across 16 public
shared stimulus sets, computed from the cache on EC2 (Gram-only, so the
feature count never enters an allocation).

Region-layer CKA between regnety_032 and seresnext50_32x4d is 0.97-0.996 --
far higher than at the readout (0.44-0.95). Two quite different architectures
have near-identical representational geometry at region layers.

Caveat carried in the data, not just prose: these entries hold concatenated
layers, so CKA is over a mixture dominated by the highest-variance block
rather than a matched single layer. The layer policy is still open.

Also de-brittles test_embeddings_returned_for_a_selected_set, which picked
row 0 and so depended on sort order -- it broke the moment region rows sorted
above the readout ones. It now looks up a set that actually has embeddings,
and a new test covers the common case of a row with a score but no embedding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant