TextObfuscator: Making Pre-trained Language Model a Privacy Protector via Obfuscating Word Representations

Xin Zhou, Yi Lu, Ruotian Ma, Tao Gui, Yuran Wang, Yong Ding, Yibo Zhang, Qi Zhang, Xuanjing HuangACL 2023 · OpenReview

Abstract

As large-scale Pre-trained Language Models (PLMs) are increasingly deployed as cloud-based services, the privacy of user data sent for inference has become a critical concern. While sending numerical embeddings instead of raw text is a common practice, these representations remain vulnerable to inversion attacks that can reconstruct original inputs with high accuracy. We present TextObfuscator, a framework that protects privacy by obfuscating word representations through functional similarity. By clustering words into task-related prototypes and adding strategic noise, TextObfuscator makes original text nearly impossible to reconstruct while maintaining, and sometimes enhancing, model performance. Our evaluation across multiple benchmarks demonstrates that TextObfuscator reduces text recovery rates from near 100% to below 7% without incurring significant utility or latency penalties.

Introduction: The Privacy Gap in Inference as a Service

The current AI landscape relies heavily on "Inference as a Service," where users send data to powerful cloud-based servers hosting massive PLMs. To mitigate privacy risks, a common defense involves generating embeddings locally and transmitting these numerical vectors. However, recent research into "Inversion Attacks" has demonstrated that these vectors can be mapped back to original text with startling accuracy, often reaching 100% recovery.

The threat model of inversion attacks in cloud-based inference services.

This vulnerability poses a significant risk for sensitive applications involving medical records or private communications. TextObfuscator addresses this by moving beyond simple noise addition to a strategy of obfuscation through functional similarity.

Methodology

TextObfuscator operates through a two-step framework designed to hide specific word identities while preserving their functional role for the target task.

The two-step TextObfuscator framework: Finding task-related prototypes and private representation training.

The system first identifies "prototypes" that represent functional categories of words:

  • Token-level tasks: For tasks like Named Entity Recognition (NER), the labels themselves serve as prototypes.
  • Sentence-level tasks: For tasks like sentiment analysis, the framework uses K-Means clustering with a TF-IDF re-division strategy. This ensures words with distinct task-related meanings (e.g., "excellent" vs. "terrible") are not grouped together despite appearing in similar contexts.

Step 2: Private Representation Training

The model is trained using a Clustering Loss, which pulls words performing the same role (e.g., different names like "John" and "Mike") toward the same mathematical prototype. During inference, Laplace Noise is added to these representations. Because the words are already clustered, the noise makes individual words within a cluster indistinguishable to an attacker, while the server can still accurately identify the functional category required for the task.

Experimental Evaluation

We evaluated TextObfuscator using roberta-base on four major benchmarks: CoNLL2003 and OntoNotes5.0 for NER, and SST-2 and AGNEWS for classification tasks.

Privacy vs. Utility

A key finding is the absence of a "privacy tax." Unlike traditional methods like Differential Privacy that often degrade performance, TextObfuscator's clustering acts as a form of regularization. On the CoNLL2003 task, it achieved an F1 score of 89.11, significantly outperforming other defense methods like DPNR (79.14) and CAPE (84.47), and remaining close to the non-private baseline of 91.72.

In terms of privacy, TextObfuscator drastically reduces the success of inversion attacks. On the SST-2 dataset, the "Top-1" recovery rate dropped from 100% (standard fine-tuning) to just 5.48%. Furthermore, unlike encryption-based methods, TextObfuscator introduces zero additional inference time, making it practical for real-world applications.

Conclusion

TextObfuscator provides a practical, high-performance solution for privacy-preserving NLP. By focusing on functional identity rather than individual word identity, it thwarts reconstruction attacks without sacrificing accuracy or increasing inference latency. Future work will explore extending this protection to broader sensitive attributes and formalizing the privacy guarantees beyond empirical results.

Summary updated

BibTeX
@inproceedings{zhou2023textobfuscator,
  author = {Xin Zhou and Yi Lu and Ruotian Ma and Tao Gui and Yuran Wang and Yong Ding and Yibo Zhang and Qi Zhang and Xuanjing Huang},
  title = {{TextObfuscator: Making Pre-trained Language Model a Privacy Protector via Obfuscating Word Representations}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=71q_J-6Ev-x},
}
Figure