Introduction
Given backbone coordinates for N, CA, C and O, we seek an amino acid sequence compatible with that structure. Geometry constrains residue identity, but it does not specify a unique sequence. Nearby residues also constrain each other: a useful structural marginal can still miss information carried by its neighbors' possible identities. Our question is how to exploit that information while retaining parallel prediction from structure alone.
The supplied literature includes deep sequence design with ProteinMPNN [1], efficient inverse folding with PiFold [2], and protein-structure learning through geometric vector perceptrons and vector-field networks [3, 4]. Denoising diffusion provides another approach to inverse folding [5]. These works frame the design space; our implementation builds specifically on a geometric vector-field encoder and adds a decoder that exchanges uncertain sequence context.
The starter uses a message-passing encoder followed by an independent multilayer readout. We replace that encoder and readout with local vector geometry, dense structural context, and a learned compatibility field. We use soft residue distributions as context so that inference need not commit to a decoding order or an early hard sequence.
Method
Local vector geometry and dense structural context
We construct a CA nearest-neighbor graph and attach a backbone frame to each residue. The encoder represents learned vectors in these local frames. A neighbor's vector is expressed in the center frame through
The submitted encoder uses 15 layers and 32 vector channels. It combines transformed neighbor vectors with center vectors, separates their directions from their lengths, and expands lengths with Gaussian features conditioned on the endpoint states. Scalar and vector attention then update the residue representation; edge states also evolve. Our encoder retains the geometric vector-field foundation [4].
def forward(self, h_V, h_E, center_id, batch_id, dst_idx=None, frame_dst=None, h_V_vector=None):
E = h_E.shape[0]
n_heads = self.num_heads
d = int(self.num_hidden / n_heads)
h_V_vector_init = h_V_vector
h_V_vector_src = h_V_vector[center_id]
h_V_vector_dst = h_V_vector[dst_idx]
h_V_vector_dst_trans = frame_dst[:, None].apply(h_V_vector_dst)
h_V_vector_edge = torch.cat([h_V_vector_dst_trans, h_V_vector_src], dim=-2)
h_V_vector_edge = self.edge_vector_field_linear(h_V_vector_edge) + h_V_vector_dst_trans
h_V_vector_dist = h_V_vector_edge.norm(dim=-1) + 1e-6
h_V_vector_edge_sin_cos = h_V_vector_edge / h_V_vector_dist[..., None]
h_V_vector_dist = self.gbf(h_V_vector_dist, h_V[center_id], h_V[dst_idx])
vector_field_feat_to_s = torch.cat([h_V_vector_edge_sin_cos.flatten(start_dim=1), h_V_vector_dist], dim=1)
h_E = torch.cat([vector_field_feat_to_s, h_E], dim=-1)
h_E = self.h_e_reducer(h_E)Above this sparse encoder, we add dense attention over the residues of each protein. Each attention head receives an additive bias , where is the CA distance and contains 8 radial basis features spanning 0 to 30. The block has 4 heads and residual attention and feed-forward updates. Its purpose is to make structural context available beyond the nearest-neighbor graph before sequence refinement begins.
def forward(self, h, ca, mask):
B, L = mask.shape
D = torch.cdist(ca, ca)
rbf = _rbf(D, D_max=30., D_count=8, device=ca.device)
bias = self.distance(rbf).permute(0, 3, 1, 2).reshape(B * self.heads, L, L)
valid = (mask.unsqueeze(1) * mask.unsqueeze(2)).bool()
bias = bias.masked_fill(~valid.repeat_interleave(self.heads, 0), -1e4)
z = self.norm1(h)
attended, _ = self.attention(z, z, z, attn_mask=bias, need_weights=False)
h = h + self.dropout(attended)
h = h + self.dropout(self.dense(self.norm2(h)))
return h * mask.unsqueeze(-1)The resulting structural states produce base logits . We retain the encoder's sparse edge states for the compatibility decoder.
Compatibility messages from expected sequence context
Let be a marginal distribution over amino acids and a learned amino acid embedding. We represent uncertain sequence context by its expectation,
Each compatibility layer learns a message and a structural attention weight:
We aggregate and apply residual updates with layer normalization and a feed-forward network. The decoder contains two such layers and returns a residual logit correction , giving . The correction's output weights and bias start at zero.
def forward(self, h, h0, h_E, seq, edge_idx):
center, neighbor = edge_idx[0], edge_idx[1]
valid = (center != neighbor).to(h.dtype)
msg = self.message(torch.cat([h0[center], h0[neighbor], h_E, seq[neighbor]], dim=-1))
scores = self.compatibility(torch.cat([h0[center], h0[neighbor], h_E], dim=-1)).squeeze(-1)
scores = scores.masked_fill(valid == 0, -1e4)
weights = scatter_softmax(scores.unsqueeze(-1), index=center, dim=0).squeeze(-1) * valid
agg = scatter_sum(msg * weights.unsqueeze(-1), center, dim=0, dim_size=h0.shape[0])
h = self.norm1(h + self.dropout(agg))
h = self.norm2(h + self.dropout(self.dense(h)))
return hBoth layers use the fixed structural endpoint states in their messages. They do not transmit a neighbor's updated sequence-aware hidden state. This matters during training: a target's native identity may serve as context for other residues, but it cannot return to its own prediction through a sequence-aware multi-hop path. Self-edge removal blocks the direct path. The field is a learned marginal update, without an explicit normalized joint sequence distribution or a specified pairwise energy.
Training with partial native context
We train the base head and field jointly. For each protein, we draw a reveal probability and independent residue indicators . The sequence embedding supplied to the field is
Thus the field sees a mixture of reliable native-neighbor context and uncertain structural predictions. Detaching the base probabilities prevents gradients through that context distribution; the structural states and residual decoder still train jointly. With averages over valid residues, our objective is
def training_loss(self, X, S, mask):
h0, h_E, edge_idx, batch_id, base_logits = self.encode_base(X, mask)
target = S[mask.bool()]
base_lp = F.log_softmax(base_logits.float(), dim=-1)
probs = base_lp.detach().exp()
ratio = torch.rand((X.shape[0], 1), device=X.device) * 0.7
reveal = (torch.rand((h0.shape[0],), device=X.device) < ratio[batch_id, 0]).float()
logits = self.refine(h0, h_E, edge_idx, base_logits, probs, (reveal, target))
lp = F.log_softmax(logits.float(), dim=-1)
loss = F.nll_loss(lp, target) + 0.3 * F.nll_loss(base_lp, target)
return loss, self.restore(lp, mask)The delivered configuration sets batch size 8 and epoch_fraction=0.45, and retains AdamW with OneCycle scheduling.
Damped inference and burial calibration
Inference begins with and uses the same structural encoding throughout. At update , we compute refined logits from the current expected sequence embeddings and damp the resulting probabilities:
We perform updates and average the trajectory, including the initial prediction:
def forward(self, X, mask):
h0, h_E, edge_idx, batch_id, base_logits = self.encode_base(X, mask)
probs = F.softmax(base_logits.float(), dim=-1)
total = probs
for _ in range(self.refine_steps):
logits = self.refine(h0, h_E, edge_idx, base_logits, probs)
updated = F.softmax(logits.float(), dim=-1)
probs = 0.5 * probs + 0.5 * updated
total = total + probs
lp = torch.log((total / (self.refine_steps + 1)).clamp(min=1e-8))Finally, we count valid CA neighbors at distances greater than and less than 10. This count is a structural proxy for burial. We bucket it at thresholds and assign temperatures . The final distribution is
Positive temperature scaling preserves the most probable residue while changing confidence. It can therefore improve perplexity without improving residue recovery. The rule depends only on coordinates and validity masks at inference.
ca = X[:, :, 1, :]
distances = torch.cdist(ca, ca)
pairs = mask.unsqueeze(1) * mask.unsqueeze(2)
burial = ((distances < 10.) & (distances > 1e-5) & (pairs > 0)).sum(-1)
bins = torch.bucketize(burial, torch.tensor([8, 16, 24, 32], device=X.device))
temperatures = torch.tensor([1.2, 1.2, 1.3, 1.4, 3.0], device=X.device, dtype=lp.dtype)
lp = F.log_softmax(lp / temperatures[bins][mask.bool()].unsqueeze(-1), dim=-1)
return self.restore(lp, mask)Results
| Method | ① | ② | ③ | |||
|---|---|---|---|---|---|---|
| Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | |
| Kimi K3.1 Pro | 4.139 | 0.544 | 4.004 | 0.533 | 3.955 | 0.539 |
| ProteinMPNN | 5.310 | 0.469 | 5.212 | 0.459 | 5.057 | 0.489 |
| PiFold | 4.811 | 0.521 | 4.574 | 0.517 | 4.857 | 0.528 |
| GVP | 6.426 | 0.407 | 6.276 | 0.400 | 6.171 | 0.417 |
| VFN-IF, as published | 4.328 | 0.540 | 4.240 | 0.531 | 4.243 | 0.560 |
| UniIF | 4.956 | 0.525 | 4.610 | 0.519 | 4.678 | 0.541 |
| ScFold | 5.049 | 0.518 | 4.659 | 0.512 | 4.813 | 0.525 |
| DIF-Large | 0.434 | 0.425 | 0.455 | |||
| MapDiff | 5.306 | 0.481 | 5.137 | 0.472 | 5.143 | 0.508 |
| ProteinMPNN, AR decoder | 5.502 | 0.474 | 5.536 | 0.461 | 5.495 | 0.489 |
| GVP, AR decoder | 6.750 | 0.409 | 6.634 | 0.406 | 6.546 | 0.420 |
| SurfFold | 9.905 | 0.280 | 9.840 | 0.282 | 9.897 | 0.286 |
| VFN-IF | 4.058 | 0.544 | 3.882 | 0.547 | 3.839 | 0.556 |
- ① CATH 4.2 · recovery / perplexity
- ② CATH 4.3 · recovery / perplexity
- ③ TS50 · trained on CATH 4.2
On CATH 4.2, we obtain recovery 0.544 and perplexity 4.139. The strongest supplied baseline, VFN-IF, has recovery 0.540 and perplexity 4.328. On CATH 4.3, our recovery is 0.533 and perplexity is 4.004, compared with VFN-IF's 0.531 and 4.240. Our recovery leads on these settings are modest in the reported means.
TS50 shows a different tradeoff. Our perplexity, 3.955, is below the best supplied baseline value of 3.839. Our recovery, 0.539, remains below VFN-IF's 0.560. We therefore improve probability quality across the reported settings without uniformly improving the most probable sequence. The supplied means include no uncertainty estimates, so they do not establish the statistical significance of the recovery differences.
How we got here
We began with the distinction between independent structural marginals and predictions conditioned on neighboring residue identities. The trace records mean-field conditional inference and orderless learning as inspirations. Our first neural field mixed native reveals with detached base predictions, then used soft updates at inference. This basic separation of structural evidence and sequence context survives in the final code.
Several experiments narrowed the decoder. An explicit low-rank pairwise-energy model improved over its development reference but trailed the nonlinear neural field. Hard contexts and sampled-context chains also underperformed soft expectations. Training through a free-running refinement trajectory did not improve the completed comparison, despite promising early measurements. Increasing the base-loss weight and adding edge-wise auxiliary prediction likewise failed to yield a reliable gain. We retained the joint base and refined marginal losses.
Dense structural context gave a modest improvement. A higher-order field then appeared promising against a sparse model, but a comparison controlling for global context did not support it. We retained the simpler field with fixed structural endpoint states. Learned compatibility attention addressed a more successful hypothesis: neighbors should contribute unequally. The trace reports selective contact weighting and a same-checkpoint improvement from refinement, supporting the routing mechanism rather than merely an improved base head.
Encoder-transfer experiments showed that a useful field did not automatically improve every stronger geometry model. We ultimately combined the field with the geometric vector encoder used in the delivered file. In our recorded development ablation, refinement added 0.84 percentage points of recovery to this encoder and lowered perplexity. That is a development measurement from the trace, distinct from the reported means above; it supports a contribution from the decoder alongside the stronger structural representation.
Later diagnostics found overconfidence and different behavior across burial ranges. We first tested a common temperature, then a burial-dependent rule, and finally stronger softening in the most buried bin. The final constants were selected empirically after inspecting multiple development collections. The trace also records that a smaller refinement depth could look slightly better on validation while the retained depth performed better on other development collections; we kept the eight-update procedure.
Limitations
The recovery deficit on TS50 limits the claim: lower perplexity does not imply a better most probable sequence. Calibration directly changes confidence, so the final perplexity advantage cannot be assigned entirely to geometric representation or compatibility learning. The supplied results do not isolate those components through matched final ablations.
Our field consumes expected amino acid embeddings. Distinct multimodal sequence contexts can have similar expectations, and repeated updates are not guaranteed to converge or optimize a joint sequence energy. Trajectory averaging stabilizes the delivered prediction but supplies no such guarantee. Training uses partial native context and a single refined prediction, whereas inference repeatedly consumes its own marginals; that mismatch remains after the unsuccessful unrolled-training experiment.
The burial thresholds and temperatures are empirical constants. Their development involved repeated inspection of labeled collections, so those diagnostics do not provide untouched confirmation of calibration transfer. A structural neighbor count also captures only a limited aspect of residue exposure.
Dense structural attention requires quadratic pair storage. The inherited featurizer has a separate implementation limitation: it constructs sequential-neighbor atom features by shifting flattened valid residues without resetting those shifts at protein boundaries. Terminal features can consequently depend on an adjacent protein in a batch. Finally, the trace records coordinate-noise sensitivity and small rotation-dependent numerical differences in a trained model; local frames alone do not establish exact numerical invariance of the delivered implementation.
References
- J. Dauparas, I. Anishchenko, N. Bennett et al. (2022). Robust deep learning–based protein sequence design using ProteinMPNN. Science.
- Zhangyang Gao, Cheng Tan, Pablo Chacón et al. (2023). PiFold: Toward effective and efficient protein inverse folding. ICLR.
- Bowen Jing, Stephan Eismann, Patricia Suriana et al. (2021). Learning from Protein Structure with Geometric Vector Perceptrons. ICLR.
- Weian Mao, Muzhi Zhu, Zheng Sun et al. (2024). De novo protein design using geometric vector field networks. ICLR.
- Peizhen Bai, Filip Miljković, Xianyuan Liu et al. (2024). Mask prior-guided denoising diffusion improves inverse protein folding.
- Zhangyang Gao, Jue Wang, Cheng Tan et al. (2024). UniIF: Unified Molecule Inverse Folding. NeurIPS.
- Jiancheng Zhong, Zhiwei Zou, Jie Qiu et al. (2025). ScFold: a GNN-based model for efficient inverse folding of short-chain proteins via spatial reduction. Briefings in Bioinformatics.
- Yasha Ektefaie, Olivia Viessmann, Siddharth Narayanan et al. (2024). Reinforcement learning on structure-conditioned categorical diffusion for protein inverse folding.
- Darong Li, Lian Shen, Meijia Song et al. (2026). SurfFold: a unified model for protein inverse folding by integrating surface and structural information. Bioinformatics.