Abstract
This paper introduces a method for performing text classification on encrypted BERT embeddings using Homomorphic Encryption (HE). By combining high-quality pre-trained representations with a custom, GPU-accelerated implementation of the CKKS encryption scheme, the authors achieve near-plaintext accuracy while providing 128-bit security against data leakage and text inversion attacks.
1. Introduction
While vector embeddings from models like BERT are fundamental to modern NLP, they are not inherently private. Research indicates these embeddings can leak sensitive user attributes and are vulnerable to "inversion attacks," where an adversary reconstructs original input text from the vector. Existing solutions often employ Differential Privacy (DP), which introduces a trade-off between privacy levels and model accuracy. Homomorphic Encryption (HE) allows for computation on encrypted data without decryption, offering a cryptographic alternative, though it has historically faced challenges regarding computational speed and model complexity.
2. Methodology
The proposed pipeline shifts language understanding to the local client while securing the classification task on the server side.
- Local Embedding: Users generate sentence embeddings locally using a pre-trained Sentence-BERT model.
- Encryption: Embeddings are encrypted using the CKKS scheme, designed for real-number arithmetic.
- Encrypted Inference: The server performs Logistic Regression on the encrypted vectors. Non-linear functions like the sigmoid are approximated using a degree-15 minimax polynomial.
- GPU Acceleration: A custom GPU implementation of CKKS with efficient bootstrapping "refreshes" ciphertext noise, enabling unlimited computations.
3. Experimental Evaluation
The approach was evaluated on three datasets: Twitter Hate Speech Detection (binary), SNIPS Intent Classification (7-class), and YouTube Spam Collection (YTSC).
3.1 Accuracy and Privacy Trade-offs
A key finding is the robustness of HE compared to noise-based privacy methods. As shown in the experimental results, models using HE (Ciphertext) maintain performance nearly identical to plaintext versions. In contrast, DP models (Noising) suffer significant accuracy and F1 degradation as privacy requirements (noise levels, denoted by η) increase.
3.2 Computational Efficiency
The method achieved a massive speedup per training epoch compared to PrivFT, a previous state-of-the-art encrypted classifier. Training that took PrivFT 60 hours on 8 GPUs was completed in approximately 23 seconds on a single GPU using the proposed method. Additionally, the encrypted models retained roughly 98.8% to 99.6% of the accuracy of the original plaintext models across the Twitter and SNIPS datasets.
4. Discussion and Limitations
The use of rich BERT embeddings allows for simpler downstream classifiers like Logistic Regression, making HE computationally feasible. While the system provides strong resistance to inversion attacks, it still faces challenges:
- Computational Overhead: Encrypted training remains significantly slower than plaintext (e.g., 143 seconds per epoch vs. negligible time).
- Storage and Bandwidth: Ciphertexts are significantly larger than plaintext; for instance, the SNIPS training set grew from ~200 MB to over 11 GB when encrypted.
- Model Complexity: Scaling beyond Logistic Regression to multi-layer neural networks would require more complex polynomial approximations and higher computational costs.
5. Conclusion
This work demonstrates that Homomorphic Encryption can be practically applied to NLP tasks by leveraging pre-trained embeddings and GPU acceleration. It provides a "hard" cryptographic guarantee of privacy with minimal impact on classification accuracy, offering a viable alternative to noise-based privacy methods.
Summary updated