TL;DR
This paper introduces SentinelLMs, a novel method to adapt and fine-tune large language models (LLMs) to process encrypted user inputs without sacrificing performance. By transforming tokenizers and embeddings, SentinelLMs enable secure inference on sensitive data, addressing critical privacy concerns in modern AI applications.
What Problem Does This Paper Address?
As LLMs become increasingly integrated into everyday applications, their deployment on cloud servers raises significant privacy and security concerns. Users transmit their data over networks, making it vulnerable to interception (e.g., Man-in-the-Middle attacks). Furthermore, organizations hosting these models may store user data, leading to privacy risks. While encryption is a natural solution, standard LLMs are trained on plain text and struggle to process encrypted inputs, often treating them as out-of-vocabulary terms. Existing encryption methods can also strip away crucial linguistic information, hindering model performance. This paper tackles the challenge of making LLMs work seamlessly with encrypted inputs while maintaining their accuracy and efficiency.
Methods
SentinelLMs proposes a two-stage approach: adaptation and fine-tuning.
- Adaptation: This is a one-time process.
- Tokenizer Encryption: The model's tokenizer vocabulary is encrypted using a keyed encryption algorithm (Blake). This allows for user-specific encryption keys.
- Token Embedding Transformation: To prevent reverse-engineering of embeddings, a distance-preserving geometric transformation (glide reflection) is applied to the token embeddings. This alters their positions in a way that preserves relative distances but makes them indecipherable.
- Vocabulary and Embedding Rearrangement: To further obscure token order, the vocabulary and embedding indices are randomly shuffled.
- Fine-Tuning: After adaptation, the model is fine-tuned on task-specific datasets where the text examples have been encrypted using the same keyed encryption method and passkey used during adaptation.
For runtime inference, user inputs are first tokenized and encrypted on the user's device (client-side) before being sent to the server. A generic tokenizer on the server then processes these encrypted inputs for the adapted model.
Datasets
The paper evaluates SentinelLMs on several standard NLP benchmarks:
- GLUE benchmark: A collection of datasets for various natural language understanding tasks, including text classification and sequence labeling.
- CoNLL2003: A dataset for Named Entity Recognition (NER).
- XNLI dataset: Used for multilingual natural language inference evaluation.
Key Insights and Ideas
- Keyed Encryption for LLMs: Using keyed encryption (like Blake) is crucial. It allows for user-specific encryption, meaning different users can have their data encrypted differently, enhancing privacy.
- Distance-Preserving Transformations: The use of glide reflections on embeddings is a clever way to obfuscate the original embedding space without destroying the relative relationships between tokens, which is vital for model performance.
- Token-Level Encryption with Shuffling: Encrypting at the token level, combined with random shuffling of vocabulary and embeddings, provides a robust defense against attacks that rely on token order or predictable patterns.
- Performance Parity: The most significant insight is that these complex encryption and transformation steps can be achieved with minimal to no performance degradation compared to models trained on plain text.
Key Results
The experimental evaluation demonstrates that SentinelLMs achieve performance parity with their original, non-encrypted counterparts across various tasks.
- GLUE Benchmark: Adapted models (e.g., EBERT, EROBERTa) showed performance within a 2% margin of original BERT and RoBERTa models on most GLUE tasks.
- Sequence Labeling (NER): Similar performance parity was observed for NER tasks.
- Multilingual XNLI: Adapted models performed comparably to original models in both in-language and zero-shot settings.
- Security: Investigations into token recoverability showed negligible accuracy (0.009%) when predicting nearest neighbors from transformed embeddings, and a mere 0.01% match in rankings after fine-tuning, indicating strong resistance to token recovery attacks.
Limitations and Future Work
- Generative Models: The current approach is primarily evaluated on encoders (like BERT and RoBERTa) and not on generative models. The authors note that generative models, with their shared tokenizers and decoders, are incompatible with the current adaptation strategy.
- Further Optimization: While performance parity is achieved, the authors suggest that refining remaining layers of the language model might require extending training iterations for certain tasks.
- Future Directions: The authors plan to expand their approach to generative models and explore improved encryption strategies for non-English and multilingual tasks. They also aim to incorporate advanced cryptographic algorithms or post-quantum encryption methods and explore multi-party computation or homomorphic encryption for enhanced security.
Summary updated