RFGM: Balancing Rare Residues in NSAA Peptide Design
- RFGM is a logit calibration strategy that adjusts predictions based on residue frequency to mitigate class imbalance in peptide design.
- It employs frequency-weighted perturbations during training to reduce over-penalization of rare non-standard amino acids.
- As part of NS-Pep, RFGM complements techniques like PSP and IAW, resulting in significant improvements in sequence recovery and binding affinity.
Residue Frequency-Guided Modification (RFGM) is a frequency-aware logit calibration strategy introduced in the NS-Pep framework for de novo peptide design with non-standard amino acids (NSAAs). Its purpose is to address the severe long-tailed residue distribution that arises when rare NSAAs are learned jointly with standard amino acids: rather than resampling the training data, it perturbs residue-type logits during training according to class frequency so that rare residues are not over-penalized as negative classes under a cross-entropy-style objective. Within NS-Pep, RFGM is the component that specifically targets residue-frequency imbalance, complementing Progressive Side-chain Perception (PSP) and Interaction-Aware Weighting (IAW) (Guo et al., 1 Oct 2025).
1. Problem setting and motivation
RFGM is motivated by the observation that NSAA-aware peptide design is dominated by an extreme class-imbalance regime. In the peptide datasets used for NS-Pep, even the most frequent NSAA, SEP, appears in less than 0.4% of residues, and the 18 most frequent NSAAs together make up only about 2% of all residues. Under ordinary cross-entropy training, standard amino acids dominate the optimization, while rare NSAA classes are repeatedly encountered as negative labels and therefore pushed downward in logit space without enough positive updates to recover. The method is introduced precisely to counter this failure mode (Guo et al., 1 Oct 2025).
The practical consequence is residue-level collapse toward head classes. The paper characterizes the naive behavior as overfitting to standard amino acids, under-representing NSAAs in predictions, collapsing toward head classes, and failing to recover rare residue identities, especially in NSAA-containing peptides. RFGM is therefore not a generic regularizer; it is a targeted long-tailed learning mechanism for generative residue prediction.
A common misconception is that the central issue is merely class rarity in the usual dataset-imbalance sense. The paper’s formulation is narrower and more specific: the main problem is that rare residue classes are over-penalized as negative labels during residue-type prediction. This distinction matters because RFGM operates on logits and gradients rather than on the empirical sample distribution.
2. Formal definition and optimization mechanism
For residue classification, NS-Pep uses a cross-entropy-style objective,
with gradient
For a negative class, this reduces to
so a rare class that is absent at most positions can accumulate repeated suppressive updates (Guo et al., 1 Oct 2025).
RFGM modifies the logits before the loss is computed: where
Here, is the number of training instances of class , is a frequency-related weight, and . The paper describes this as “injecting frequency-weighted perturbations into the residue-type logits.”
The essential design choice is the scale factor . Because 0 is larger for rarer classes, the perturbation scale is smaller for tail classes and larger for head classes. The paper explicitly notes that this may look counterintuitive at first, but argues that after calibration it leads to lower expected gradient penalties for rare classes.
This makes RFGM distinct from data-level balancing methods such as weighted sampling. Weighted sampling increases the occurrence of rare residues in minibatches and changes the data distribution; RFGM instead alters the optimization dynamics while leaving the dataset intact. The paper also contrasts RFGM with BLV (Balancing Logit Variation), which uses the opposite scaling direction: 1 Accordingly, RFGM and BLV share a noise-injection template but differ in the frequency scaling that governs which classes receive larger perturbations.
3. Theoretical analysis
The appendix provides a gradient-based justification for RFGM. Its first statement, presented as Lemma 1, is that if a nonnegative perturbation 2 is added to a logit 3, then the cross-entropy gradient with respect to that logit increases: 4 The reason given is that increasing a logit increases its softmax probability 5, and the gradient magnitude is proportional to 6 (Guo et al., 1 Oct 2025).
The paper then analyzes a two-class setting with a frequent class 7 and a rare class 8, using perturbation scales 9. It shows that the rare class has a greater than 0.5 chance of receiving a reduced gradient penalty under RFGM: 0 The derivation relies on the fact that the noise ratio 1 from two Gaussian variables has a known arctangent distribution, yielding
2
The interpretation given in the paper is that rare classes are less likely to be overly penalized, while head classes are more likely to receive stronger negative-class penalties. In the multi-class case, the argument is formulated in expectation: denoting expected perturbation magnitudes as 3, the modified softmax probabilities satisfy that the most frequent class tends to have 4, the rarest class tends to have 5, and intermediate classes lie between these extremes. This supports the claim that RFGM redistributes gradient pressure away from tail classes and toward head classes.
A plausible implication is that RFGM should be understood less as a direct rare-class booster than as a mechanism for reassigning negative-class suppression. The paper’s analysis is consistent with that reading.
4. Position within NS-Pep
RFGM is one of three core components in NS-Pep: RFGM handles the residue-frequency imbalance, PSP improves side-chain modeling, and IAW emphasizes residues near the binding pocket (Guo et al., 1 Oct 2025).
In the full training objective,
6
RFGM is applied to the residue-type branch 7. It therefore modifies the sequence-generation part of the model, while PSP addresses side-chain geometry and IAW reweights positions near the interface.
This division of labor is important for interpreting the method’s scope. RFGM does not replace side-chain modeling or interface-aware weighting; it addresses a narrower bottleneck, namely the suppression of rare residue logits in the residue-type flow-matching loss. The broader NS-Pep framework uses this together with geometric and interaction-aware components. In the abstract, the overall framework is reported to improve sequence recovery rate and binding affinity by 6.23% and 5.12%, respectively, and to outperform AlphaFold3 by 17.76% in peptide folding success rate. Those gains belong to NS-Pep as a whole rather than to RFGM in isolation.
5. Empirical behavior, ablations, and comparative performance
The paper evaluates RFGM against weighted sampling, BLV, and Seesaw loss on the NSAA test set. In the PepFlow* setting, the baseline AAR(NS) is 2.08%; weighted sampling reaches 4.76%; BLV remains at 2.08%; Seesaw gives 0.30%; and RFGM reaches 19.05%. The paper explicitly states that RFGM improves AAR(NS) by 16.97% in that setting. It also reports AAR 30.72%, RMSD 3.60 Å, and AFF 26.04% for the RFGM-equipped PepFlow* configuration (Guo et al., 1 Oct 2025).
With side-chain perception included, the best NS-Pep configuration achieves AAR 32.36%, AAR(NS) 29.77%, RMSD 3.94 Å, and AFF 26.39%. The paper states that the model without long-tailed handling performs much worse on NSAA recovery, indicating that the imbalance correction is essential rather than optional.
Ablation on the stochastic noise term further isolates the contribution of RFGM’s perturbation mechanism. For NS-Pep, the reported numbers are as follows:
| Configuration | Recovery metrics | Structural metric |
|---|---|---|
| With RFGM | AAR 22.53%, AAR(SEP) 0.57%, AAR(TYS) 64.29%, AAR(PTR) 56.25%, AAR(NS) 29.77% | RMSD 4.92 Å |
| Without noise | AAR 15.81%, AAR(SEP) 7.39%, AAR(TYS) 41.07%, AAR(PTR) 64.58%, AAR(NS) 26.79% | RMSD 5.82 Å |
The paper interprets this as evidence that the noise perturbation plays a meaningful role in sequence learning, and also notes that removing noise hurts both RFGM and BLV, but especially BLV. This is used to support the claim that RFGM’s benefit is not merely generic regularization noise.
The method is also evaluated in an expanded 38-class setting covering 18 NSAA types. There, PepFlow* recovers only 1.43% on average for NSAA recovery, while NS-Pep reaches 29.36%. The paper further reports individual recoveries including SEP 44.44%, PTR 59.66%, DLY 63.02%, SAR 45.31%, and MVA 37.50%. This suggests that the method generalizes beyond a very small subset of common NSAAs.
6. Interpretation, scope, and terminological disambiguation
Within peptide design, RFGM denotes a residue-frequency-guided modification of logits for long-tailed residue prediction. Its defining feature is that it directly targets the problem that rare classes are over-penalized as negative labels in cross-entropy, rather than changing the sampling distribution or adding a generic class-balanced loss (Guo et al., 1 Oct 2025).
The acronym is, however, not unique across recent literature. In "Beyond Illumination: Fine-Grained Detail Preservation in Extreme Dark Image Restoration" (Zhang et al., 5 Aug 2025), RFGM denotes the Residual Fourier-Guided Module, a first-stage component for global frequency-domain restoration in extremely dark image enhancement. That module restores global illumination and structural priors in the Fourier domain by modeling inter-stage and inter-channel dependencies through residual connections. Although the acronym matches, the object of study is unrelated to residue-frequency imbalance in peptide generation.
A second nearby usage appears in "A modified-residue prescription to calculate dynamical correlation functions" (Benek-Lins et al., 9 Apr 2025). There, the paper’s central method is the modified-residue prescription (mRes), and the details describe it as closely related to a broader concept of Residue Frequency-Guided Modification (RFGM): the singular part of an integrand is identified from its known asymptotic form, and the usual cell weight in numerical quadrature is replaced by a residue-derived weight guided by the frequency-dependent singularity. This is a numerical integration strategy for many-body response calculations, not a logit-calibration method.
Because of these overlapping acronym uses, precise domain context is necessary. In the NS-Pep literature, RFGM refers specifically to the frequency-aware calibration mechanism for long-tailed residue prediction with NSAAs; in dark image restoration it refers to a Fourier-domain residual module; and in coarse-grid response-function integration it is associated with a residue-guided modification of quadrature weights.