File size: 10,972 Bytes
3b59775
 
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
8f616d4
 
2e30570
 
3b59775
2e30570
 
 
8f616d4
 
 
 
 
 
 
 
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f616d4
 
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f616d4
 
 
 
 
 
 
2e30570
 
 
 
 
 
 
8f616d4
 
 
2e30570
 
 
8f616d4
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
8f616d4
 
 
 
 
 
 
2e30570
 
 
 
8f616d4
2e30570
 
 
 
 
 
 
c606a20
8f616d4
 
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f616d4
 
 
 
2e30570
 
 
 
 
 
de2d4e6
2e30570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
license: cc-by-4.0
pretty_name: Residue-aligned protein embeddings, sequence and structure models, every layer
tags:
  - biology
  - proteins
  - protein-language-models
  - representation-similarity
  - embeddings
size_categories:
  - 10K<n<100K
configs:
  - config_name: residues
    data_files: residues.csv
  - config_name: chains
    data_files: chains.csv
  - config_name: proteins
    data_files: proteins.csv
  - config_name: reference_scores
    data_files: reference_scores.csv
---

# Residue-aligned protein embeddings: sequence and structure models, every layer

Nine model arms — sequence models (ESM-2 35M and 650M, CARP-38M), structure models (ProteinMPNN,
ESM-IF1), two copies of ESM-1v that differ only by random seed, and untrained copies of ESM-2 35M
and ProteinMPNN — each describing the same proteins at every layer, in two parts:

- **Residue level:** 10,045 residues from 35 whole protein domains, aligned row for row across
  all nine arms, with structural and functional labels per residue.
- **Protein level:** one vector per protein (the mean over its residues) for 4,894 protein
  domains, every arm and layer, with fold, kingdom and function labels per protein.

It is built as a test bed for measures of representation similarity (CKA, SVCCA, mutual
k-NN and others). The seeded ESM-1v pair is a ceiling for how alike two models can be, the
untrained copies are floors, and the sequence–structure pairs sit in between. Reference scores
for twelve pairs are included, so an implementation can be checked against known values on
identical inputs.

Produced by [seq-structure-convergence](https://github.com/Natalija-Stepurko/seq-structure-convergence),
which studies whether a sequence model and a structure model learn the same biology;
[results](https://natalija-stepurko.github.io/seq-structure-convergence/).

## Why it is useful

- **Known answers at both ends.** Measures of representation similarity are usually tested on
  pairs whose true relationship is unknown. Here the range is fixed: two copies of ESM-1v that
  differ only by random seed set the ceiling (seeded copies of one protein model are rarely
  released), untrained copies set the floor, and the sequence–structure pairs sit in between.
  A new measure can be checked for whether it orders these correctly.
- **A genuinely cross-modal pair.** The sequence models never see coordinates and the structure
  models never see the sequence, yet both describe the same residues, row for row. Pairs like this
  are hard to find outside proteins.
- **Every layer.** Where in a network a property appears, and where two
  networks agree, can be studied directly, without re-running any model.
- **Widths from 128 to 1,280 dimensions.** Several similarity measures drift with representation
  width even on unrelated data; the range here makes that effect testable.
- **A shared training target to control for.** All trained models output amino-acid identity,
  which by itself produces agreement. The residue table carries the amino acid, so methods for
  removing a shared target can be tested against the reference scores computed with and without
  it.
- **Reference values to test code against.** Implementations of CKA, SVCCA and nearest-neighbour
  overlap differ in details (centring, row caps, neighbour counts). `reference_scores.csv` gives
  72 values on these exact inputs, each beside its score on scrambled data.
- **Labels for probing.** Secondary structure, solvent accessibility, burial, flexibility and
  binding, active and modification sites per residue; fold class, kingdom and function per protein.
- **Protein-level comparisons at scale.** The protein-level part covers 4,894 domains, enough for
  protein properties such as CATH fold class or enzyme class to be well represented, in 1.4 GB.
- **It saves compute.** Producing these tensors takes the model weights, three separate software
  environments (ESM-IF1 and CARP have conflicting dependencies) and several hours of computation.

## Model arms

| File (`embeddings/`) | Model | Reads | Layers | Dim | Size |
|---|---|---|---|---|---|
| `esm2_35m.safetensors` | ESM-2 35M (`esm2_t12_35M_UR50D`) | sequence | 13: input embedding + 12 blocks | 480 | 125 MB |
| `esm2_650m.safetensors` | ESM-2 650M (`esm2_t33_650M_UR50D`) | sequence | 34: input embedding + 33 blocks | 1280 | 874 MB |
| `esm1v_seed1.safetensors` | ESM-1v (`esm1v_t33_650M_UR90S_1`) | sequence | 34 | 1280 | 874 MB |
| `esm1v_seed2.safetensors` | ESM-1v (`esm1v_t33_650M_UR90S_2`), same model, different seed | sequence | 34 | 1280 | 874 MB |
| `carp_38m.safetensors` | CARP-38M (convolutional) | sequence | 4: blocks 4, 8, 12, 16 of 16 | 1024 | 82 MB |
| `proteinmpnn.safetensors` | ProteinMPNN encoder (`v_48_020`) | backbone coordinates | 3 encoder layers | 128 | 8 MB |
| `esmif1.safetensors` | ESM-IF1 (`esm_if1_gvp4_t16_142M_UR50`) | backbone coordinates | 1: encoder output | 512 | 10 MB |
| `esm2_35m_untrained.safetensors` | ESM-2 35M architecture, random weights | sequence | 13 | 480 | 125 MB |
| `proteinmpnn_untrained.safetensors` | ProteinMPNN encoder, random weights | backbone coordinates | 3 | 128 | 8 MB |

Sizes are for the residue-level files. The same nine files under `embeddings_protein/` are
together 1.4 GB (ESM-2 650M and each ESM-1v copy 426 MB; the rest under 62 MB each).

Each residue-level file holds one tensor, `layers`, float16, shape `[n_layers, 10045, dim]`; row
`k` is the same residue in every file and in `residues.csv`. Each protein-level file holds
`layers` of shape `[n_layers, 4894, dim]`; row `k` is the same protein in every file and in
`proteins.csv`. The structure models never see the sequence
and the sequence models never see coordinates; all trained models are trained to output
amino-acid identity, which is a source of agreement between them.

## Files

| File | Contents |
|---|---|
| `embeddings/*.safetensors` | residue level: the nine arms above, 10,045 residues |
| `embeddings_protein/*.safetensors` | protein level: the nine arms, one mean vector per protein, 4,894 proteins |
| `proteins.csv` | one row per protein, in protein-level tensor order: PDB ID, chain, length, CATH code and levels, UniProt accession, kingdom, enzyme class, protein class, localisation |
| `residues.csv` | one row per residue, in tensor order: chain, position, amino acid, secondary structure (helix / sheet / coil), relative solvent accessibility, buried (RSA < 0.25) or exposed, per-chain-normalised B-factor, binding / active / PTM site flags |
| `chains.csv` | one row per chain: PDB ID, chain, length, CATH code and levels, UniProt accession, kingdom, enzyme class, protein class, localisation |
| `reference_scores.csv` | CKA, SVCCA and mutual k-NN for twelve pairs on these residues, raw and with the per-amino-acid mean subtracted, each beside a scrambled-residue null |
| `arms.json`, `arms_protein.json` | layer count, dimension and size per arm, for each part |

## Loading

```python
from huggingface_hub import snapshot_download
from safetensors.numpy import load_file
import pandas as pd

path = snapshot_download("NatalijaStepurko/seq-structure-convergence", repo_type="dataset",
                         allow_patterns=["residues.csv", "embeddings/esm2_35m.safetensors",
                                         "embeddings/proteinmpnn.safetensors"])
seq = load_file(f"{path}/embeddings/esm2_35m.safetensors")["layers"]     # (13, 10045, 480)
struct = load_file(f"{path}/embeddings/proteinmpnn.safetensors")["layers"]  # (3, 10045, 128)
residues = pd.read_csv(f"{path}/residues.csv")

# protein level: one vector per protein, e.g. the last layer of ESM-2 35M against CATH class
path = snapshot_download("NatalijaStepurko/seq-structure-convergence", repo_type="dataset",
                         allow_patterns=["proteins.csv", "embeddings_protein/esm2_35m.safetensors"])
prot = load_file(f"{path}/embeddings_protein/esm2_35m.safetensors")["layers"]  # (13, 4894, 480)
proteins = pd.read_csv(f"{path}/proteins.csv")
X, y = prot[-1], proteins["cath_class"]
```

The three 650M-parameter arms are 874 MB each; `allow_patterns` fetches only what you need.

## How the proteins were chosen

From the 4,898 non-redundant CATH S35 domains with experimental structures used in the parent
study, chains were taken in a random order (seed 42), keeping only chains that every arm
describes in full, until the total reached 10,000 residues. Chains are whole, so estimates can
be resampled by chain: residues within a chain are correlated, and resampling them
independently understates the spread.

The protein-level part keeps the 4,894 of the 4,898 domains that all nine arms describe in full. Each vector is the mean over the protein's residues, in float32, stored as float16 — the
pooling the parent study's protein-level probes use.

## Reference scores

`reference_scores.csv` has, per pair, mode and measure: the layer pair used (`layer_a`,
`layer_b`, indices into the tensors), the score, and the score with one model's rows shuffled
(`scrambled`), which is what the measure reports for unrelated data. The layer pair is the
one at which the parent study found that pair's peak; `partial` subtracts each residue's
per-amino-acid mean from both models before measuring.

These values depend on the sample. CKA, SVCCA and mutual k-NN are all biased upward at smaller
sample sizes, and unequally, so they are comparable within this dataset and not against numbers
computed on a different number of residues. The implementations in the parent repository
(`src/ssc/metrics.py`) evaluate SVCCA on at most 5,000 rows and mutual k-NN (k = 10) on at most
4,000; the reference values use those defaults.

## Limits

- The residue-level part has 35 proteins: enough for residue-level comparisons. Protein-level
  questions belong on the protein-level part, which covers 4,894.
- Mean pooling discards where in the protein a signal sits; the protein-level vectors suit
  protein properties, not residue ones.
- The structure models are inverse-folding encoders; no structure-prediction model (such as
  AlphaFold) is included.
- CARP is stored at four of its sixteen blocks.

## Provenance

Built by `scripts/07_hf_dataset.py` in the parent repository (`--protein-level` for the protein-level part) from the per-residue
embeddings written by `scripts/02_extract.py`.

## Licence and attribution

CC BY 4.0. The models are MIT-licensed (fair-esm, ProteinMPNN, sequence-models). The labels
come from CATH (CC BY 4.0), UniProt (CC BY 4.0), RCSB PDB (CC0) and SIFTS (EMBL-EBI); when you
use them, credit CATH (Sillitoe et al., 2021), UniProt (The UniProt Consortium, 2023) and SIFTS
(Dana et al., 2019).

## Citation

```bibtex
@misc{stepurko2026seqstructure,
  author = {Stepurko, Natalija},
  title  = {Residue-aligned protein embeddings from sequence and structure models},
  year   = {2026},
  url    = {https://huggingface.co/datasets/NatalijaStepurko/seq-structure-convergence}
}
```