Introduction
Privacy-Preserving Machine Learning (PPML) is becoming increasingly critical as Large Language Models (LLMs) handle more sensitive user data. Homomorphic Encryption (HE) offers a robust cryptographic solution by allowing computations to be performed directly on encrypted data. However, HE is natively restricted to polynomial operations (addition and multiplication). This creates a significant "math gap" for standard Transformer architectures, which rely heavily on non-polynomial functions like Softmax (exponentials and divisions), LayerNorm (square roots), and GELU.
Previous attempts to bridge this gap often relied on high-degree polynomial approximations that were either too slow or introduced excessive noise, limiting polynomial-based models to roughly 100 million parameters. This paper introduces Power-Softmax, a redesign of the self-attention mechanism that is natively compatible with HE constraints, enabling the scaling of secure LLMs to 1.4 billion parameters—a tenfold increase over previous state-of-the-art polynomial models.
The Power-Softmax Architecture
The core innovation is replacing the exponential-based Softmax with a stable, polynomial-based variant. The authors propose three primary modifications to ensure stability and efficiency within HE environments.
1. Power Scaling and Normalization
Instead of the standard $e^x$ scaling, Power-Softmax uses $x^p$ (where $p$ is a positive even integer). This provides the necessary "amplification" of high scores—essential for attention—while remaining a simple polynomial. To maintain numerical stability and prevent exploding values, the inputs are divided by their maximum norm during training.
2. Lipschitz-Stable Division
Division is notoriously difficult to approximate with polynomials, especially near zero. The authors introduce a $\frac{1}{\epsilon^2}$-Lipschitz division, adding a small constant $\epsilon$ to denominators. This prevents the "division by zero" spikes that typically degrade approximation accuracy.
3. Length-Agnostic Approximation
In standard attention, the denominator sum grows with the sequence length ($L$), making it difficult to find a single polynomial approximation that works for varying input sizes. Power-Softmax instead normalizes by the mean of the scores. Since the mean is statistically more stable than the sum as $L$ increases, the division operation becomes much easier to approximate with a low-degree polynomial using algorithms like Goldschmidt division.
Empirical Behavior and Scaling
The fundamental hypothesis is that the specific exponential form of Softmax is not strictly necessary for the "emergent" properties of LLMs. As long as the function is monotonic and amplifies differences between scores, the model can learn to utilize it effectively.
As shown in the comparison above, higher values of $p$ allow the power function to more closely mimic the "winner-take-all" behavior of Softmax. By integrating these HE-friendly components, the researchers successfully trained a 1.4 billion parameter model ("Poly-Pythia") with 32 layers.
Key Results and Performance
The authors evaluated Power-Softmax across a wide range of benchmarks, including GLUE for bidirectional models and various reasoning tasks (ARC, PIQA, WinoGrande) for generative models.
- Reasoning & In-Context Learning (ICL): The 1.4B Poly-Pythia model achieved zero-shot and 5-shot results comparable to vanilla Transformers. For instance, on the ARC-Easy task, the Poly model scored 0.602, nearly matching the original's 0.617.
- Classification Accuracy: A polynomial RoBERTa-Base reached 93.35% on SST-2, significantly outperforming previous HE-friendly variants like Nexus.
- Efficiency: In encrypted inference tests, the Power-Softmax operation accounted for only 6% of total latency. While Matrix Multiplication remains the primary bottleneck (~67%), the efficiency of the new attention mechanism ensures it does not hinder overall performance.
Conclusion and Future Work
Power-Softmax represents a significant step toward practical secure LLM inference. By scaling polynomial models by an order of magnitude, it proves that privacy-preserving architectures can maintain competitive reasoning capabilities. While current HE inference remains slower than plaintext, future work will focus on further reducing multiplicative depth to bring secure LLMs closer to real-time usability.
Summary updated