A Constrained Optimization Perspective of Unrolled Transformers
Javier Porras-Valenzuela, Samar Hadou, Alejandro Ribeiro
TL;DR
The paper addresses transformer fragility under perturbations and distribution shifts by enforcing layerwise descent of the loss using a constrained, dual-structured learning problem. The authors develop a primal--dual training algorithm, proving a Constrained Learning Theorem that bounds the duality gap and an asymptotic convergence result, and they establish OOD generalization guarantees under distribution shifts. Empirically, constrained transformers show improved robustness with minimal or no sacrifice to in-distribution performance across video denoising and text classification with perturbed embeddings, and extend to large-scale models such as Llama in finetuning scenarios. These findings suggest that imposing monotone layerwise descent is a practical and scalable strategy to enhance transformer robustness in real-world, perturbed settings.
Abstract
We introduce a constrained optimization framework for training transformers that behave like optimization descent algorithms. Specifically, we enforce layerwise descent constraints on the objective function and replace standard empirical risk minimization (ERM) with a primal-dual training scheme. This approach yields models whose intermediate representations decrease the loss monotonically in expectation across layers. We apply our method to both unrolled transformer architectures and conventional pretrained transformers on tasks of video denoising and text classification. Across these settings, we observe constrained transformers achieve stronger robustness to perturbations and maintain higher out-of-distribution generalization, while preserving in-distribution performance.
