Understanding Privacy Risks of Embeddings Induced by Large Language Models
Zhihao Zhu Ninglu Shao Defu Lian Chenwang Wu Zheng Liu Yi Yang Enhong Chen




Large language models (LLMs) show early signs of artificial general intelligence but struggle with hallucinations. One promising solution to mitigate these hallucinations is to store external knowledge as embeddings, aiding LLMs in retrieval-augmented generation. However, such a solution risks compromising privacy, as recent studies experimentally showed that the original text can be partially reconstructed from text embeddings by pre-trained language models. The significant advantage of LLMs over traditional pre-trained models may exacerbate these concerns. To this end, we investigate the effectiveness of reconstructing original knowledge and predicting entity attributes from these embeddings when LLMs are employed. Empirical findings indicate that LLMs significantly improve the accuracy of two evaluated tasks over those from pre-trained models, regardless of whether the texts are in-distribution or out-of-distribution. This underscores a heightened potential for LLMs to jeopardize user privacy, highlighting the negative consequences of their widespread use. We further discuss preliminary strategies to mitigate this risk.




Understanding Privacy Risks of Embeddings Induced by Large Language Models
    Zhihao Zhu, Ninglu Shao, Defu Lian, Chenwang Wu, Zheng Liu, Yi Yang, Enhong Chen
    April 29, 2024
====================================================================================





§ INTRODUCTION


Large language models <cit.> have garnered significant attention for their exceptional capabilities across a wide range of tasks like natural language generation <cit.>, question answering <cit.>, and sentiment analysis <cit.>. 

Nonetheless, it's observed that large language models can confidently assert non-existent facts during their reasoning process. For example, Bard, Google's AI chatbot, concocted information in the first demo that the James Webb Space Telescope had taken the first pictures of a planet beyond our solar system <cit.>. Such a hallucination problem <cit.> of large language models is a significant barrier to artificial general intelligence <cit.>. A primary strategy for tackling the issue of hallucinations is to embed external knowledge in the form of embeddings into a vector database <cit.>, making them accessible for retrieval augmented generation by large language models <cit.>.

An embedding model <cit.> encodes the original objects' broad semantic information by transforming the raw objects (e.g., text, image, user profile) into real-valued vectors of hundreds of dimensions. The advancement of large language models enhances their ability to capture and represent complex semantics more effectively, such that an increasing number of businesses (e.g., OpenAI <cit.> and Cohere <cit.>) have launched their embedding APIs based on large language models. 
Since embeddings are simply real-valued vectors, it is widely believed that it is challenging to decipher the semantic information they contain. Consequently, embeddings are often viewed as secure and private, as noted by  <cit.>, leading data owners to be less concerned about safeguarding the privacy of embeddings compared to raw external knowledge. However, in recent years, multiple studies <cit.> have highlighted the risk of embeddings compromising privacy. More specifically, the pre-trained LSTM (Long Short-Term Memory) networks <cit.> or other language models can recover parts of the original texts and author information from text embeddings, which are generated by open-source embedding models. Although current studies have exposed security weaknesses in embeddings, the effects of large language models on the privacy of these embeddings have not been fully explored. A pressing issue is whether LLMs' emergent capabilities enable attackers to more effectively decipher sensitive information from text embeddings. This issue is driven not only by the proliferation of large language models but also by the availability of the embedding APIs based on LLMs, which permits attackers to gather numerous text-embedding pairs to build their attack models.

To this end, we establish a comprehensive framework that leverages a large language model (LLM) to gauge the potential privacy leakage from text embeddings produced by the open-sourced embedding model. From a security and privacy perspective, LLM serves as the attacker, and the embedding model acts as the target, while the goal is to employ the attack model to retrieve sensitive and confidential information from the target model. Specifically, our approach begins with fine-tuning attack models to enable text reconstruction from the outputs of the target model. Following this, we assess the privacy risks of embeddings via two types of attack scenarios. On the one hand, we recover the texts from their embeddings in both in-distribution and out-of-distribution scenarios. On the other hand, we identify certain private attributes of various entities in the original text (such as birthdays, nationalities, criminal charges, etc.) and predict these attributes from the text embeddings. This prediction is determined by the attribute that exhibits the highest cosine similarity between the text embedding and the corresponding attribute embedding. Consequently, this method does not necessitate training with supervised data. Should the target embedding model decline to generate embeddings for attributes with extremely brief texts described (1-2 words) out of embedding stealing concerns, we introduce an external embedding model that acts as a proxy to project the original text and the attribute value in the same embedding space. Specifically, this external model is tasked with embedding the attribute and the text reconstructed by the attack model, the latter being derived from text embeddings produced by the target embedding model.

The evaluation of text reconstruction reveals that 1) a larger attack language model, when fine-tuned with a sufficient amount of training data, is capable of more accurately reconstructing texts from their embeddings in terms of metrics like BLEU <cit.>, regardless of whether the texts are in-distribution or out-of-distribution; 2) in-distributed texts are more readily reconstructed than out-of-distributed texts, with the reconstruction accuracy for in-distributed texts improving as the attack model undergoes training with more data; 3) the attack model can improve the reconstruction accuracy as the expressiveness of the target embedding models increases.

The evaluation of attribute prediction demonstrates that 1) attributes can be predicted with high accuracy across various domains, including encyclopedias, news, medical, and legislation. This means the attacker is capable of inferring details like a patient's health condition, a suspect's criminal charges, and an individual's birthday from a set of seemingly irrelevant digital vectors, highlighting a significant risk of privacy leakage; 2) generally speaking, enlarging the scale of the external/target embedding model substantially enhances the accuracy of attribute prediction; 3) when the target model denies embedding services for very short texts, the most effective approach using reconstructed text by the attack model can achieve comparable performance to using original text, when the target model and the external embedding model are configured to be the same.

From the experiments conducted, we find that knowledge representations merely through numerical vectors encompass abundant semantic information. The powerful generative capability of large language models can continuously decode this rich semantic information into natural language. If these numerical vectors contain sensitive private information, large language models are also capable of extracting such information. The development trend of large language models is set to increase these adverse effects, underscoring the need for our vigilance. Our research establishes a foundation for future studies focused on protecting the privacy of embeddings. For instance, the finding that accuracy in text reconstruction diminishes with increasing text length indicates that lengthening texts may offer a degree of privacy protection. Furthermore, the ability of the attack model to reconstruct out-of-distributed texts points towards halting the release of original texts associated with released embeddings as a precaution.



§ MAIN RESULTS



 §.§ Fine-Tuning the Attack Model


We employ pre-trained GPT2 <cit.> of varying sizes as the attacking model to decipher private information from embeddings produced by the target embedding models such as SimCSE <cit.>, BGE-Large-en <cit.>, and E5-Large-v2 <cit.>. We hypothesize that larger embedding models, due to their capacity to capture more information, are more likely to be exposed to a greater privacy risk. Consequently, all these models are designated as the target models, and their numbers of parameters are detailed in Table <ref>. It's important to note that we treat the target model as a black box, meaning we do not have access to or knowledge of its network architecture and parameters. Figure <ref> showcases the fine-tuning process for the attack model. Initially, the example text “David is a doctor.” is inputted into the target embedding model to generate its respective embedding. This embedding is then used as the input for the attack model, which aims to reconstruct the original text based solely on this embedding. An EOS (End-of-Sentence) token is appended to the text embedding to signal the end of the embedding input. The attacker's training goal is to predict the t-th token of the original text based on text embedding and the preceding (t-1) tokens of the original text. In the testing phase, the attacker employs beam search <cit.> to progressively generate tokens up to the occurrence of the EOS. Once the attack model has been fine-tuned, we evaluate the privacy risks of embeddings through two distinct attack scenarios: text reconstruction and attribute prediction.








 §.§ Evaluation of Text Reconstruction





 §.§ Settings

For each text in the test set, we reconstruct it using the attack model based on its embedding generated by the target model. To evaluate the reconstruction accuracy, we employ two metrics: BLEU (Bilingual Evaluation Understudy) <cit.> and ROUGE (Recall-Oriented Understudy for Gisting Evaluation) <cit.>. 
Specifically, we utilize BLEU-1 and ROUGE-1, which are based solely on unigrams, as they yield better results compared to BLEU and ROUGE based on other n-grams <cit.>. These metrics gauge the similarity between the original and reconstructed texts. Given that the temperature setting influences the variability of the text produced by GPT, a non-zero temperature allows for varied reconstructed texts given the same text embedding. We calculate the reconstruction accuracy across 10 trials to obtain mean and standard error for statistical analysis. Based on these outcomes, we compare the performance of various attack and target configurations using a two-sided unpaired t-test <cit.>. The evaluation is conducted on seven datasets, including wiki <cit.>, wiki-bio <cit.>, cc-news <cit.>, pile-pubmed <cit.>, triage <cit.>, cjeu-terms <cit.>, and us-crimes <cit.>. Details and statistics for these datasets are presented in Table <ref>.



 §.§ Results of In-Distributed Texts

We create three subsets from the wiki dataset of varying sizes (i.e., wiki-small, wiki-large, and wiki-xl) and use these subsets to fine-tune the attack models, resulting in three distinct versions of the attack model. The performance of these attack models is then assessed using held-out texts from the wiki dataset. The experimental results presented in Table <ref> illustrate that the size of the training datasets and the models have a considerable influence on the reconstruction accuracy. To elaborate, 
regardless of the attack model employed, it's found that larger embedding models, such as BGE-Large-en and E5-Large-v2, enable more effective text reconstruction compared to others like SimCSE. This is attributed to the strong expressivity of the large target embedding model, which allows it to retain more semantic information from the original text, proving beneficial for the embedding's application in subsequent tasks. Moreover, provided that the attack model is adequately fine-tuned and the embedding model is expressive enough, the accuracy of text reconstruction improves as the size of the attack model increases. This improvement is reflected in the table's last two columns, showing higher accuracy as the attack model progresses from GPT2 to GPT2_large, and finally to GPT2_xl, attributed to the improved generative capabilities of larger models. Additionally, adequately fine-tuning the large language models is a prerequisite for their effectiveness in text reconstruction tasks. When the embeddings are less informative, fine-tuning the attack model demands a larger amount of training data. This is highlighted by the lesser performance of GPT2_xl compared to GPT2 when fine-tuning with wiki-small, which reverses after fine-tuning with Wiki-xl. Moreover, GPT2_xl outperforms GPT2 in reconstructing text from SimCSE's embeddings as the fine-tuning dataset shifts from “Wiki-large" to “Wiki-xl".

To summarize, a larger attack model, when fine-tuned with an increased amount of training data, is capable of more accurately reconstructing texts from the embeddings generated by target embedding models with higher expressivity. Hence, a straightforward approach for safeguarding privacy involves not disclosing the original dataset when publishing its embedding database. Nonetheless, it remains to be investigated whether an attack model, fine-tuned on datasets with varying distributions, would be effective.
















 §.§ Results of Out-of-Distributed Texts

To address the unresolved question, we assume that the attacker model is trained on the Wiki dataset with more rigorous descriptions of world knowledge, yet the texts used for testing do not originate from this dataset. This implies that the distribution of the texts used for testing differs from that of the texts used for training. We assess the reconstruction capability of this attack model on sample texts from six other datasets: wiki_bio, cc_news, pile_pubmed, triage, us_crimes, and cjeu_terms. The results presented in Table <ref> show that the attack model retains the capability to accurately reconstruct texts from the embeddings, even with texts derived from different distributions than its training data. In greater detail, the best reconstruction accuracy of the attack model on texts from 5 out of 6 datasets is equal to or even exceeds that of a model fine-tuned on wiki-small, a relatively small subset of Wikipedia. As a result, if we release embeddings for the wiki_bio, cc_news, pile_pubmed, us_crimes, and cjeu_terms datasets, an attack model fine-tuned on the Wiki-xl dataset can extract semantic information from them with relatively high confidence. This suggests that simply withholding the original raw data does not prevent an attacker from reconstructing the original text information from their released embeddings. 


To understand which kind of text data is more easily recovered from text embedding based on the attack model fine-tuned with Wiki-xl, we also analyze the similarity between the six evaluation datasets and Wiki based on previous works <cit.>. The results reported in figure <ref> show that texts from evaluation datasets with higher similarity to the training data are reconstructed more accurately. To elaborate, Wiki-bio, which compiles biographies from Wikipedia, shares the same origin as the training dataset. Despite covering different content, the language style is very similar. Consequently, the quality of the attack's text reconstruction for this dataset is the highest. In other words, simply withholding the original text associated with embeddings does not adequately safeguard sensitive information from being extracted, as fine-tuning the attack model with datasets that are similar in terms of language style or content can elevate the risk of privacy breaches. 



The disclosure of even a small collection of original texts significantly amplifies the risk, as illustrated in figure <ref> which presents results from the pile-pubmed dataset where the attack model undergoes further fine-tuning with these original texts. The availability of more original texts linked to the embedding directly correlates with an increased risk of sensitive information leakage. Specifically, the BLEU-1 score for GPT2-xl against the BGE-large-en embedding model sees a 2% increase when the attack model is supplemented with 10k original texts. Notably, even with the use of a limited amount of target data (1K samples), the improvements in BLEU-1 score are considerable.

In summary, concealing the datasets of published embeddings does not effectively prevent information leakage from these embeddings. This is because their underlying information can still be extracted by an attack model that has been fine-tuned on datasets of similar style or content. Furthermore, revealing even a small number of samples can significantly improve the extraction accuracy.







 §.§ Results of Varying Text Lengths

Given GPT's capability to generate outputs of varying lengths with consistent meanings, exploring how text length impacts reconstruction quality becomes pertinent. With the average text length in the Wiki dataset being 21.32, as noted in Table <ref>, we selected three subsets: Wiki-base, Wiki-medium, and Wiki-long, each with 5,000 samples but average lengths of 20, 40, and 80 words, respectively. Among them, Wiki-medium and Wiki-long are created by extending texts in Wiki-base via the GPT4 API <cit.> accessible by OpenAI. 


The results of text reconstruction are depicted in figure <ref>. 
It's evident that embeddings from shorter texts are more susceptible to being decoded, posing a greater risk to privacy. For example, the ROUGE-1 score of GPT2-xl on BGE-Large-en fell by over 43.3% as the test text length increased from Wiki-base to Wiki-long. This decline can be attributed to the fixed length of text embeddings, which remain constant regardless of the original text's length. Consequently, embeddings of longer texts, which encapsulate more information within the same embedding size, make accurate text recovery more formidable. Therefore, extending the original texts could potentially fortify the security of released embeddings.











 §.§ Evaluation of Sensitive Attribute Prediction






 §.§ Settings

In contrast to text reconstruction, our primary concern is whether the attacker can extract specific sensitive information from the text embeddings. The task of predicting sensitive attributes more clearly illustrates the issue of privacy leakage through embeddings, compared to the task of reconstructing text. Initially, we pinpoint sensitive or crucial data within the datasets: wiki-bio, triage, cjeu-terms, and us-crimes. In particular, we examined patient dispositions and blood pressure readings in the triage dataset, and in the wiki-bio dataset, we focused on individuals' nationality, birthdate, and profession. Additionally, we looked into criminal charges in the us_crimes dataset and considered legal terminology as important information in the cjeu_terms dataset. Given the extensive variety of attributes and the scarcity of labeled data for each, it's impractical for the privacy attacker to train a dedicated model for each sensitive attribute, unlike the approach taken in previous studies <cit.>. Therefore, we predicted the sensitive information from text embedding by selecting the attribute that exhibits the highest cosine similarity between text embedding and its embedding. This approach is effective across various attributes and does not necessitate training with supervised data. However, a challenge arises because the text describing the attribute is often very brief (sometimes just a single word), and the target embedding model may refuse to produce embeddings for such short texts due to concerns about embedding theft <cit.>. As a result, it becomes difficult to represent the original text and the attribute value within the same embedding space. To overcome this, we introduce an external embedding model to serve as an intermediary. This external model is responsible for embedding both the attribute and the reconstructed text, which has been derived from text embeddings by the attack model. Consequently, texts and attributes are embedded within the same space via reconstructing texts from the text embeddings, allowing for accurate similarity measurement. The overall process for inferring attributes is depicted in figure <ref>. The outcomes of the attribute inference attack using various methods are presented in Table <ref>. The last row of this table, which relies on the similarity between attributes and original texts, lacks randomness in its measurement due to the direct comparison method employed. In contrast, the preceding rows, which are based on reconstructed texts, introduce randomness into the similarity measurement. This variability stems from employing a non-zero temperature setting, allowing for multiple independent text generations to produce diverse outputs.



 §.§ Results


The findings presented in Table <ref> reveal that sensitive information can be accurately deduced from text embeddings without the necessity for any training data, highlighting a significant risk of privacy leakage through embeddings. Specifically, attributes such as nationality and occupation can be inferred with high precision (an accuracy of 0.94) even when using texts that have been reconstructed. This level of accuracy is attributed to the embeddings' ability to capture the rich semantic details of texts coupled with the attack model's strong generative capabilities. Remarkably, the accuracy of predictions made using an external embedding model on reconstructed texts is on par with those made using the target embedding model on original texts in several cases. For an equitable comparison, the external embedding model was set to be identical to the target embedding model, although, in practice, the specifics of the target embedding model might not be known. The inference accuracy improves when employing a larger attack model for text reconstruction and a more expressive embedding model. This outcome aligns with observations from text reconstruction tasks. Although the accuracy of attribute prediction with reconstructed text falls short in some instances compared to using original texts, the ongoing advancement in large language models is rapidly closing this gap. Hence, the continuous evolution of these models is likely to escalate the risks associated with privacy breaches, emphasizing the critical need for increased awareness and caution in this domain.



§ DISCUSSIONS AND LIMITATIONS

This study delves into the implications of large language models on embedding privacy, focusing on text reconstruction and sensitive information prediction tasks. Our investigation shows that as the capabilities of both the sophisticated attack foundation model and the target embedding model increase, so does the risk of sensitive information leakage through knowledge embeddings. Furthermore, the risk intensifies when the attack model undergoes fine-tuning with data mirroring the distribution of texts linked to the released embeddings.

To protect the privacy of knowledge embeddings, we propose several strategies based on our experimental findings:



  * Cease the disclosure of original texts tied to released embeddings: Preventing the attack model from being fine-tuned with similar datasets can be achieved by introducing imperceptible noise into the texts or embeddings. This aims to widen the gap between the dataset of original or reconstructed texts and other analogous datasets.

  * Extend the length of short texts before embedding: Enhancing short texts into longer versions while preserving their semantic integrity can be accomplished using GPT-4 or other large language models with similar generative capacities.

  * Innovate new privacy-preserving embedding models: Develop embedding models capable of producing high-quality text embeddings that are challenging to reverse-engineer into the original text. This entails training models to minimize the cloze task loss while maximizing the reconstruction loss.


However, our study is not without limitations. Firstly, due to substantial training expenses, we did not employ an attack model exceeding 10 billion parameters, though we anticipate similar outcomes with larger models. Secondly, while we have quantified the impact of various factors such as model size, text length, and training volume on embedding privacy, and outlined necessary guidelines for its protection, we have not formulated a concrete defense mechanism against potential embedding reconstruction attacks. Currently, effective safeguards primarily rely on perturbation techniques and encryption methods. Perturbation strategies, while protective, can compromise the embedding's utility in subsequent applications, necessitating a balance between security and performance. Encryption methods, though secure, often entail considerable computational demands. Future work will explore additional factors influencing embedding privacy breaches and seek methods for privacy-preserving embeddings without sacrificing their utility or incurring excessive computational costs.



§ METHODS



 §.§ Preliminary

Prior to delving into the attack strategies, we will commence with the introduction of the language models and evaluation datasets.


 §.§ Language Model

A language model is a technique capable of assessing the probability of a sequence of words forming a coherent sentence. Traditional language models, such as statistical language models <cit.> and grammar rule language models <cit.>, rely on heuristic methods to predict word sequences. While these conventional approaches may achieve high predictive accuracy for limited or straightforward sentences within small corpora, they often struggle to provide precise assessments for the majority of other word combinations. With increasing demands for the precision of language model predictions, numerous researchers have advocated for neural network-based language models <cit.> trained on extensive datasets. The performance of neural network-based language models steadily increases as model parameters are increased and sufficient training data is received. 
Upon reaching a certain threshold of parameter magnitude, the language model transcends previous paradigms to become a Large Language Model (LLM). The substantial parameter count within LLMs facilitates the acquisition of extensive implicit knowledge from corpora, thereby fostering the emergence of novel, powerful capabilities to handle more complex language tasks, such as arithmetic operations <cit.> and multi-step reasoning <cit.>. These capabilities have enabled large language models to comprehend and resolve issues like humans, leading to their rising popularity in many aspects of society. However, the significant inference capacity of large language models may be leveraged by attackers to reconstruct private information from text embeddings, escalating the risk of privacy leakage in embeddings.



 §.§ Datasets for Evaluation



In this paper, we assess the risk of embedding privacy leaks on seven datasets, including wiki <cit.>, wiki-bio <cit.>, cc-news <cit.>, pile-pubmed <cit.>, triage <cit.>, cjeu-terms <cit.>, and us-crimes <cit.>. Wiki collects a large amount of text from the Wikipedia website. Since it has been vetted by the public, the text of the wiki is both trustworthy and high-quality.
Wiki-bio contains Wikipedia biographies that include the initial paragraph of the biography as well as the tabular infobox. CC-News (CommonCrawl News dataset) is a dataset containing news articles from international news websites. It contains 708241 English-language news articles published between January 2017 and December 2019. Pile-PubMed is a compilation of published medical literature from Pubmed, a free biomedical literature retrieval system developed by the National Center for Biotechnology Information (NCBI). It has housed over 4000 biomedical journals from more than 70 countries and regions since 1966. Triage records the triage notes, the demographic information, and the documented symptoms of the patients during the triage phase in the emergency center. Cjeu-term and us-crimes are two datasets from the legal domain. Cjeu-term collects some legal terminologies of the European Union, while us-crimes gathers transcripts of criminal cases in the United States. 

For wiki, cc_news, and pile_pubmed datasets, we randomly sample data from the original sets instead of using the entire dataset because the original datasets are enormous. 
To collect the sentence texts for reconstruction, we utilize en_core_web_trf <cit.>, an open-source tool, to segment the raw data into sentences. Then, we cleaned the data and filtered out sentences that were too long or too short. The statistical characteristics of the processed datasets are shown in Table <ref>.



 §.§ Ethics Statement

For possible safety hazards, we abstained from conducting attacks on commercial embedding systems, instead employing open-source embedding models. Additionally, the datasets we utilized are all publicly accessible and anonymized, ensuring no user identities are involved. To reduce the possibility of privacy leakage, we opt to recover more general privacy attributes like occupation and nationality in the attribute prediction evaluation rather than attributes that could be connected to a specific individual, such as phone number and address. The intent of our research is to highlight the increased danger of privacy leakage posed by large language models in embeddings, suggest viable routes to safeguard embedding privacy through experimental analysis, and stimulate the community to develop more secure embedding models.



 §.§ Threat Model



 §.§ Attack Goal

This paper primarily investigates the extraction of private data from text embeddings. Given that such private data often includes extremely sensitive information such as phone numbers, addresses, and occupations, attackers have ample motivation to carry out these attacks. For instance, they might engage in illegal activities such as telecommunications fraud or unauthorized selling of personal data for economic gain. These practices pose significant threats to individual privacy rights, potentially lead to economic losses, increase social instability, and undermine trust mechanisms.




 §.§ Attack Knowledge

To extract private information from text embeddings, attackers require some understanding of the models responsible for generating these embeddings. Intuitively, the more detailed the attacker's knowledge of the target embedding model, including its internal parameters, training specifics, etc., the more potent the attack's efficacy. However, in real-world scenarios, to safeguard their intellectual property and commercial interests, target models often keep their internal information confidential, providing access to users solely through a query interface 𝒪. 
Based on the above considerations, this study assumes that attackers only possess query permissions to the target embedding model, which responds with the corresponding text embedding based on the text inputted by the attacker. This query process does not reveal any internal information about the model. Furthermore, with the increasing popularity of large language models, numerous companies are opting to release their anonymized datasets for academic research purposes. Therefore, this study also assumes that attackers have the capability to gather specific open-source data (e.g., Wikipedia in our evaluation) and leverage interactions with target models to acquire associated text embeddings. Clearly, such low-knowledge attack settings help simulate real attack scenarios and more accurately assess the risks of embedding privacy leaks.



 §.§ Attack Methodology



 §.§ Attack Model Construction
 
Attackers reconstructed original text from text embedding by training an attack model. However, they lack prior knowledge about which architecture should be used for the attack model. When using neural networks as the attack model, it is challenging to decide which neural network architecture should be employed. If the architecture of the attack model is not as expressive and complex as the embedding model, then it is difficult to ensure that it can extract private information.

Considering the exceptional performance of large language models across various domains, particularly in text comprehension <cit.> and information extraction <cit.>, employing them as attack models could be an appropriate choice. Based on these considerations, this study utilizes GPT-2 models of varying sizes as attack models, training them to reconstruct the original text from the embeddings. 

Training set generation. We start by retrieving the text embeddings from the collected open-source data D using the query interface 𝒪 of the target embedding model. 

    e_w = 𝒪(w)

Then, we construct the training dataset D_train for the attack model based on these embeddings and corresponding texts.

    D_train = {(d_w, w)|w ∈ D, d_w = (e_w, <EOS>)}

where EOS(End-of-Sentence) token is a special token appended to the text embedding to signify the end of the embedding input.

The attack model performs the opposite operation compared to the embedding model: for each sample (d_w, w)∈ D_train, the attack model strives to recover the original text w from the embedding e_w.

Attack model training. 
For each embedding input d_w, the attack model is trained to output the first token of the original text.
Subsequently, when the attacker provides d_w along with the first i-1 tokens of the original text, the attack model is tasked with predicting the i-th token of the original text with utmost accuracy. Formally, for a sample (d_w, w), the text reconstruction loss of the attack model is as follows:

    L_θ(d_w,w) = - ∑_i=1^llog P(x_i|d_w,w_<i,θ)

where w_<i=(x_1, ..., x_i-1) represents the first i-1 tokens of the original text w. l denotes the length of w and θ represents the parameter of the attack model. 
Therefore, the training loss for the attack models is the sum of the text reconstruction loss across all samples in the training dataset:

    L_θ = - ∑_(d_w, w) ∈ D_train L_θ(d_w, w)


To evaluate the effectiveness of the attack models, we employ two tasks: text reconstruction and attribute prediction.



 §.§ Text Reconstruction Task
 
Reconstructed text generation. In the text reconstruction task, the attack models aim to generate reconstructed text that closely resembles the original text. 
When generating a reconstructed text of length l, the attacker aims for the generated text to have the highest likelihood among all candidate texts, which is formalized as follows:

    w^* = max_w={x_1, ..., x_l} P(x_1, ..., x_l|d_w,θ)

However, on the one hand, the number of candidate tokens for x_i in the reconstructed text w is large, often exceeding 10,000 in our experiments. On the other hand, the number of candidate texts exponentially increases as the text length l grows. As a result, it becomes infeasible to iterate through all candidate texts of length l and select the one with the highest likelihood as the output. 
A viable solution is greedy selection, which involves choosing the candidate token with the highest likelihood while progressively constructing the reconstructed text.

    x_i^* = max_x_i P(x_i|d_w,θ,w_ i^*)


    w^*=(x_1^*, ..., x_l^*)

However, this approach may easily lead the generation process into local optima. To enhance the quality of the reconstructed text and improve generation efficiency, we employ beam search in the text reconstruction task.
In beam search, if the number of beams is k, the algorithm maintains k candidates with the highest generation probability at each step. Specifically, in the initial state, for a given input text embedding e_w, the attack model first records k initial tokens with the highest generation likelihood (ignoring eos token) as candidate texts of length 1 (𝒞_1^*).

    𝒞_1^* = max_𝒞_1⊂𝒳, |𝒞_1|=k∑_x ∈𝒞_1 P(x|d_w,θ)

where 𝒳 represents the set of all tokens in the attack model.

Subsequently, these k initial tokens are combined with any token in 𝒳 to create a text set of length 2. The attack model then iterates through these texts of length 2 and selects k texts with the highest generation likelihood as candidate texts of length 2 (𝒞_2^*). 

    𝒞_2^* = max_|𝒞_2|=k∑_(x_1,x_2) ∈𝒞_2 P(x_1,x_2|d_w,θ)


    𝒞_2⊂{(x_1,x_2)|x_1 ∈𝒞_1^*,x_2 ∈𝒳}

This process continues, incrementing the text length until the model generates an EOS token signaling the end of the generation process.

Evaluation metric. We adopt BLEU-1 and ROUGE-1 to evaluate the reconstruction performance of the attack model, measuring how similar the reconstructed text w' is to the original text w. The formulas for these two metrics are as follows:



    BLEU-1 = BP ·∑_x ∈set(w')min(count(x, w), count(x, w'))/∑_x ∈set(w')count(x, w')


    ROUGE-1 = ∑_x ∈set(w)min(count(x, w), count(x, w'))/∑_x ∈set(w)count(x, w)



where set(w) and set(w') are the sets of all tokens in w and w'. Count(x, w) and count(x, w') are the number of times x appears in w and w', respectively. The brevity penalty (BP) is used to prevent short sentences from getting an excessively high BLEU-1 score. BLEU-1 primarily assesses the similarity between the reconstructed text and the original text, whereas ROUGE-1 places greater emphasis on the completeness of the reconstruction results and whether the reconstructed text can encompass all the information present in the original text.

Dataset similarity calculation. We assess the similarity between the evaluation datasets and the wiki dataset based on a simple character n-gram comparison <cit.>. 
Specifically, we employed the 5000 commonly used 4-gram characters in English as the feature set ℱ of the dataset. Each dataset is then represented as a 5000-dimensional feature vector.

    F_D = [count(f_1,D),..., count(f_5000,D)]

where f_i ∈ℱ is a 4-gram character, and count(f_i,D) is the number of times f_i appears in dataset D.
Finally, we calculate the Spearman correlation coefficient between the feature vectors of the two datasets to quantify their similarity.

    Sim(D_1, D_2) = Spearman(F_1, F_2)

where F_1 and F_2 are feature vectors of D_1 and D_2, respectively. The Spearman coefficient ranges from -1 to 1, where a higher value indicates a greater similarity between the two corresponding datasets.





 §.§ Attribute Prediction Task

In the attribute prediction task, this study focuses on the attacker's ability to extract private information from the original text. We chose several private attributes from four datasets and evaluated the attack model's ability to infer the precise values of these private attributes from the released text embedding. For example, in the wiki-bio dataset, occupation is chosen as a private attribute. The attacker attempts to ascertain that the original text contains the private message “doctor" by using the embedding of the sentence “David is a doctor." 

Instead of training the attack model to perform the attribute prediction task, this study utilizes the embedding similarity between the text and the attribute value to determine the suggested attribute value of the original text. Its rationality is that the text contains relevant information about sensitive attributes, so their embeddings should be similar. The ideal approach would be to determine based on the similarity between embeddings of the original text and sensitive attribute embeddings. However, this poses challenges: (1) The original text is unknown. (2) Privacy attributes are often short texts, and in most cases, consist of only one word; such frequent anomalous (short) inputs might be considered malicious attempts and rejected. Therefore, this study (1) uses reconstructed text instead of the original text, and (2) employs an open-source external embedding model as a proxy to obtain embeddings instead of using the target embedding model.  
It's worth noting that this study did not directly search for privacy attributes in the reconstructed text due to potential inaccuracies in reconstructing privacy attributes, such as missing tokens or reconstructing synonyms of the attributes.

Specifically, the attacker initially acquires embeddings of the reconstructed text and sensitive attribute from their proxy embedding model, subsequently computing the cosine similarity between them, and ultimately selecting the attribute with the highest similarity as the prediction result. Formally, the attacker infers the sensitive attribute w_v as follows:

    w_v = max_v ∈ℂ_ve_w'· e_v/|e_w'| |e_v|

where ℂ_v is the set of candidate attribute values, w_v is the predicted attribute value of the original text w. e_w' and e_v are the embedding vectors of reconstructed text w' and attribute value v with the aid of the external embedding model, respectively. We employ accuracy as the metric to evaluate the performance of the attack model on the attribute prediction task.






ACM-Reference-Format






