Protein-Looking Is Not Fold-Aware
Masked sequence models are good at producing plausible amino acids. Plausible isn't the same as compatible with the residues that have to meet in three-dimensional space.
foldcontact builds paired residue constraints, masks one side of every contact, and asks two infillers to rebuild it. One samples from the amino-acid alphabet. The other has to respect the contact class.
The Contact Map Gets a Vote
The guided decoder treats hydrophobic, charged, and polar compatibility as a hard selection signal, and every prediction stays inspectable. No checkpoint is hiding the decision. It's a small reproduction of a structure-aware design idea, not a structure predictor, built to isolate what geometric constraints are worth before anyone scales the architecture.
The Number
Random infilling satisfies 34.5% of 1,440 held-out contacts. Contact-guided infilling satisfies 100%. The controlled benchmark is educational, not a wet-lab claim, and as the next section shows, that 100% isn't the number to quote.
The Perfect Score Was Definitional
The guided infiller picks each residue by maximizing exactly the predicate it's then scored on: chemical-group compatibility. Every group has at least one self-compatible member, so a compatible pick always exists and the metric can't miss. Across 40 seeds, guided satisfaction is exactly 1.0 every time, with zero variance. It wasn't measuring inference. It was re-checking the rule the method satisfies by construction.
So I asked a question that can't be gamed: did the guess match the true residue from before masking? Narrowing to a compatible group still leaves up to four real candidates. Guided infilling recovers the true residue 24.9% of the time across 40 tuning seeds and 25.2% on a disjoint 25-seed holdout, evaluated once, against 8.2% and 8.6% for naive infilling, which is right at the 1-in-12 chance rate. That's a real, roughly threefold improvement, and a much more honest picture than 100% versus 34.5%.
The original module is untouched, so the published numbers still reproduce exactly. 10 tests pass on GitHub Actions across Python 3.9 through 3.13.
Research Basis
Inspired by the 2025 AtomWorks and RosettaFold-3 release. Every number on this page comes from this repository's own controlled benchmark, not from the paper.
Try It
Standard library only:
git clone https://github.com/ahmeddoghri/foldcontact && cd foldcontact
python foldcontact.py # the tautological 100%
python foldcontact_v2.py # true-residue recovery: 8.8% naive vs 25.6% guided
python eval_v2.py # 65 seeds: the 100% never moves, the real metric does