Abstract Text classifiers are regularly applied to personal texts, leaving users of these classifiers vulnerable to privacy breaches. We propose a solution for privacy-preserving text classification that is based on Convolutional Neural Networks (CNNs) and Secure Multiparty Computation (MPC). Our method enables the inference of a class label for a personal text in such a way that (1) the owner of the personal text does not have to disclose their text to anyone in an unencrypted manner, and (2) the owner of the text classifier does not have to reveal the trained model parameters to the text owner or to anyone else. To demonstrate the feasibility of our protocol for practical private text classification, we implemented it in the PyTorch-based MPC framework CrypTen, using a well-known additive secret sharing scheme in the honest-but-curious setting. We test the runtime of our privacy-preserving text classifier, which is fast enough to be used in practice.
Introduction
Text classification is a ubiquitous task in modern computing, powering everything from spam filters to sentiment analysis. However, standard implementations require a significant privacy trade-off. Typically, a user (Bob) must send raw, unencrypted text to a service provider's (Alice) server. This exposes the user's sensitive data to potential breaches or misuse. Conversely, the service provider cannot simply send the model to the user, as the model represents proprietary intellectual property and may inadvertently leak information about its training data.
While Secure Multiparty Computation (MPC) has been successfully applied to private image classification using 2D CNNs, applying these techniques to deep learning for text has remained challenging. This work introduces a practical method for private text classification using 1-dimensional CNNs and MPC, demonstrating that privacy does not have to come at the cost of performance or accuracy.
Methodology and Protocol Design
The core of the proposed solution is a protocol named $\pi_{TEXT}$, implemented using CrypTen, a PyTorch-based framework for MPC. The protocol relies on Additive Secret Sharing, where data is split into "shares" distributed between Alice and Bob. In this state, neither party can discern the original values; the actual result is only revealed when shares are combined at the final step.
To ensure efficiency, the system utilizes a hybrid approach. Bob first performs Public Preprocessing by converting his text into a numerical embedding vector using a publicly available BERT-based model (stsb-distilbert-base). Because the model is public, this step does not compromise Alice's proprietary classifier. The resulting embeddings are then secret-shared to initiate the MPC protocol.
CNN Architecture for Private NLP
The choice of model architecture is critical for MPC efficiency. While recurrent architectures like LSTMs are common in NLP, their sequential dependencies make them computationally expensive in an MPC setting. The authors instead utilize 1D Convolutional Neural Networks, which are significantly more "MPC-friendly."
As shown in the architecture diagram, the model processes the 1x768 embedding vector through multiple parallel branches of 1D convolutions with varying filter sizes (1x4, 1x8, 1x16), followed by pooling layers. These features are concatenated and passed through dense layers to produce the final classification. The authors adapted standard MPC subprotocols for these layers, including approximations for non-linear functions like ReLU and Sigmoid.
Experimental Setup
The model was evaluated using the Software portion of the Amazon Customer Reviews Dataset, consisting of 132,084 reviews. The task was binary sentiment analysis, where reviews with 4-5 stars were labeled "positive" and those with 1-3 stars were labeled "negative." The dataset was split into 80% for training and 20% for validation, with an average review length of approximately 64 words.
Results and Discussion
A key finding of this research is that the transition from plaintext computation to MPC resulted in zero accuracy loss. The model achieved an accuracy of 85% in both environments. In terms of performance, the system proved highly feasible for real-world use:
- Sequential Runtime: A single text instance can be classified in approximately 0.74 seconds.
- Batching Efficiency: By processing 1,000 instances simultaneously, the communication overhead is amortized, reducing the per-instance runtime to roughly 0.11 seconds.
This efficiency is largely attributed to the use of 1D CNNs, which avoid the complex dependencies of LSTMs, and the strategic use of batching to minimize communication rounds between parties.
Limitations and Future Work
While promising, the current approach has limitations. It assumes the availability of a public BERT model for preprocessing; if a proprietary embedding layer were required, the computational cost would rise significantly. Additionally, the "honest-but-curious" security model assumes parties follow the protocol, which may not suffice against truly malicious actors. Future research could explore private feature extraction from raw text and alternative MPC schemes, such as three-party computation, to further enhance efficiency and security.
Summary updated