Skip to main content
QUICK REVIEW

[Paper Review] LLMs Can Understand Encrypted Prompt: Towards Privacy-Computing Friendly Transformers

X. Liu, Zhuotao Liu|arXiv (Cornell University)|May 28, 2023
Privacy-Preserving Technologies in DataComputer Science7 citations
TL;DR

This paper proposes a privacy-computing friendly transformer architecture that replaces privacy-unfriendly nonlinear operations—such as GELU, softmax, and layer normalization—with efficient, homomorphic encryption (HE) and secure multiparty computation (MPC)-compatible alternatives. By substituting these computationally heavy components, the framework achieves a 5× speedup and 80% reduction in communication overhead compared to state-of-the-art methods like Iron, while preserving nearly identical model accuracy on LLM inference.

ABSTRACT

The community explored to build private inference frameworks for transformer-based large language models (LLMs) in a server-client setting, where the server holds the model parameters and the client inputs its private data (or prompt) for inference. However, these frameworks impose significant overhead when the private inputs are forward propagated through the original LLMs. In this paper, we show that substituting the computation- and communication-heavy operators in the transformer architecture with privacy-computing friendly approximations can greatly reduce the private inference costs while incurring very minor impact on model performance. Compared to state-of-the-art Iron (NeurIPS 2022), our privacy-computing friendly model inference pipeline achieves a $5 imes$ acceleration in computation and an 80% reduction in communication overhead, while retaining nearly identical accuracy.

Motivation & Objective

  • To address the high computational and communication overhead in private inference of transformer-based LLMs using homomorphic encryption (HE) and secure multiparty computation (MPC).
  • To identify privacy-computing unfriendly operators—such as GELU, softmax, and layer normalization—as the primary performance bottlenecks in private LLM inference.
  • To design privacy-computing friendly approximations of these nonlinear operators that maintain model accuracy while drastically reducing cryptographic cost.
  • To evaluate the end-to-end performance of the modified model in terms of inference time, communication cost, and accuracy under private computation.

Proposed method

  • The authors implement a private inference system fully supporting HE and MPC for transformer-based LLMs, enabling secure computation on encrypted inputs.
  • They identify GELU, softmax, and layer normalization as the dominant cost contributors in private inference, accounting for over 70% of total cost.
  • They replace these operators with privacy-computing friendly alternatives: ReLU for GELU, polynomial approximations for softmax, and simplified normalization layers.
  • The modified model is fine-tuned to preserve performance, ensuring that accuracy remains nearly identical to the original model under private inference.
  • The system leverages HE for linear operations and MPC for nonlinear operations, with optimized data encoding and batching strategies.
  • Communication and computation costs are measured end-to-end across multiple LLMs (BERT-Tiny, BERT-Medium, RoBERTa-Base), comparing the original and modified models.
Figure 1: Ratio of various operators’ cost
Figure 1: Ratio of various operators’ cost

Experimental results

Research questions

  • RQ1What are the primary computational and communication bottlenecks in private inference of transformer-based LLMs when using HE and MPC?
  • RQ2Can privacy-computing friendly approximations of nonlinear operators (e.g., GELU, softmax, layer normalization) significantly reduce inference overhead without sacrificing model accuracy?
  • RQ3How does the performance of the proposed framework compare to state-of-the-art private inference systems like Iron in terms of speed and communication efficiency?
  • RQ4To what extent does replacing nonlinear operators with HE/MPC-friendly alternatives affect the end-to-end accuracy of private LLM inference?
  • RQ5Can the proposed method scale across different LLM architectures (e.g., BERT-Tiny, RoBERTa-Base) while maintaining high efficiency and privacy guarantees?

Key findings

  • The proposed privacy-computing friendly model reduces private inference time by up to 5.7× compared to Iron on RoBERTa-Base, achieving 168.43s vs. 84.50s for the original model.
  • Communication costs are reduced by up to 5.6×, from 6.38GB in the original model to 1.14GB in the optimized version on RoBERTa-Base.
  • The framework achieves an 80% reduction in overall private inference cost, with the most significant savings coming from replacing GELU, softmax, and normalization layers.
  • End-to-end private inference on the modified BERT-Tiny model achieves slightly higher accuracy than plaintext inference on the original model, indicating performance stability or improvement.
  • The communication cost of the optimized model is 13% of the original model’s cost, demonstrating substantial efficiency gains in data transmission.
  • The model maintains nearly identical accuracy to the original model across all evaluated datasets, confirming minimal performance degradation despite architectural modifications.
Figure 2: Accuracies of the model before and after each substitution. We use $-$ mark to denote which operators have been replaced. The changes are done incrementally. For example, “ $-$ Softmax” means both GELU and Softmax are replaced with privacy-computing friendly alternatives.
Figure 2: Accuracies of the model before and after each substitution. We use $-$ mark to denote which operators have been replaced. The changes are done incrementally. For example, “ $-$ Softmax” means both GELU and Softmax are replaced with privacy-computing friendly alternatives.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.