A Different Level Text Protection Mechanism With Differential Privacy
Qingwen Fu


Simulating the Galactic population of axion clouds around stellar-origin black holes: 
 Gravitational wave signals in the 10 - 100 kHz band
    Jacob R. Sprague^1, Shane L. Larson^1, Zhiyuan Wang^2, Shelby Klomp^2, Andrew Laeuger^3, George Winstone^2, Nancy Aggarwal^4, Andrew A. Geraci^2, and Vicky Kalogera^1
 (The LSD Collaboration)
    September 9, 2024
===================================================================================================================================================================================================


    


§ ABSTRACT


With the widespread application of differential privacy in text protection, however, the current text cleaning mechanism based on metric local differential privacy (MLDP) is not applicable to non-metric semantic similarity measurement, and cannot achieve a good trade-off between privacy and practicality. And currently when we perform differential privacy on long text data, all text data will be perturbed. This method of perturbing all texts may be relatively effective for downstream tasks on some data sets, but if applied to long text data, it may have a great impact on the overall meaning of the text. Therefore, in this article, we propose to use the weights of different words in the pre-trained model to assign different weight parameters to words of different importance. Perform differential perturbations. In addition to conducting inference attacks, we also use large models to perform privacy and validity tests on our perturbed data.


§ INTRODUCTION


In many natural language processing (NLP) applications, input text often contains sensitive information that can infer the identity of a specific person <cit.>. In addition, legal restrictions such as CCPA and GDPR may further restrict the sharing of sensitive text data. This makes it difficult for NLP service providers to collect training data unless the privacy concerns of data owners (including individuals and institutions) are properly addressed.

A lot of work has been done to address privacy issues <cit.> to train language models using differential privacy (DP)<cit.> , which is considered the standard for privacy-preserving computing. These methods protect the data source by adding noise to the gradient or training data. However, they require service providers to collect raw data for LM training, which may still cause privacy leakage.

In order to fundamentally solve the privacy leakage problem, data needs to be fundamentally protected. Typically, these privacy mechanisms <cit.> work by replacing the original tokens in the original document with new tokens extracted from the output token set. To generate a cleaned text document. Specifically, they adopt metric local differential privacy (MLDP, also known as dχ-privacy) to provide privacy and practicality guarantees. MLDP<cit.> inherits the idea of DP and ensures that the output of any adjacent input tokens is indistinguishable to protect the original tokens from being inferred. On the other hand, MLDP preserves the utility of the purified text by assigning higher sampling probabilities to tokens that are semantically closer to the original tokens. In these mechanisms, any metric distance (such as Euclidean distance) can be used to measure the semantic similarity between tokens.

In the paper  <cit.>", an MLDP-based concept is proposed to assign a smaller custom output set to each input token to achieve token-level privacy protection. This method is an improvement on the santext<cit.> method, which increases the text perturbation rate without reducing the privacy protection effect by limiting the size of the output set. The custom parameter K can be adjusted to determine the output set size of each input token to achieve different utility-privacy trade-offs, and an improved CusText+ mechanism is proposed to skip stop words when sampling to achieve higher utility.
This analysis does improve the perturbation efficiency of words in the text to a certain extent,
but according to all previous studies, they treat every token that appears in the text equally, which actually perturbs all tokens in the text equally, which may not cause much performance impact on datasets for specific tasks. However, it will cause loss of meaning in common long texts, especially in some medical datasets or long text novels. If all words are treated equally and deemed equally important, and are perturbed to the same extent, this will greatly affect the effectiveness of the text data and lose some of the information we need. Therefore, we propose a method based on a pre-trained BERT model. Using the BERT pre-trained model, the attention weights of all tokens in the sample are extracted, and then the weights of the multi-head multi-layer Transformer are averaged and regularized. This regularized weight is used to symbolically represent the importance of each word in the sample. According to this importance parameter, words of different importance are selectively perturbed. This can reduce the damage to the effectiveness of the text to a certain extent. We tested it on two public datasets, SST-2 and QNLI, and proved the effectiveness of our method of extracting words of different importance.



§ RELATED WORK


When discussing privacy risks and protection measures in natural language processing (NLP), we can see three main research directions: research on privacy attacks on deep learning models, differential privacy (DP) and its application in NLP, and the application of local differential privacy (LDP).

First, privacy attacks against deep learning models, especially language models (LMs), have become an important research area. For example, <cit.> proposed a classification for recovering sensitive attributes or parts of original text from text embeddings output by popular LMs without relying on the structure or pattern of the input text. <cit.> demonstrated a black-box attack against GPT-2, capable of extracting verbatim text of the training data. These studies show that privacy attacks on LMs are realistic and damaging, so it is crucial to develop defenses with strict safeguards.

Secondly, in terms of Differential Privacy (DP) and its application in NLP, DP has become the de facto standard for statistical analysis. For example, some research attempts to inject high-dimensional DP noise into text representations <cit.> but these methods fail to achieve a good balance between privacy and utility, mainly because of the “dimensionality Curse". Another approach is to learn private text representations through adversarial training <cit.>, where the adversary model is trained to infer sensitive information together with the master model , while the master model is trained to maximize the adversary's loss and minimize the main learning objective.

Third, the application of local differential privacy (LDP) also plays an important role in NLP. LDP allows data owners to sanitize data locally before sending it to the server. This means data owners can share information without revealing the content of their original data. In NLP applications, LDP is particularly valuable because it can collect and analyze text data while protecting user privacy. For example, the LDP mechanism can be used to generate sanitized text datasets that can be used to train machine learning models without exposing personal information. The challenge of LDP is to achieve privacy protection while maintaining data practicality, especially when dealing with text data with complex structure and high-dimensional features.

To sum up, the NLP field faces multiple challenges when dealing with privacy protection issues. On the one hand, effective defense strategies need to be developed against privacy attacks on LMs; on the other hand, differential privacy and local differential privacy provide a series of solutions to protect the privacy of text data. These studies not only help improve the privacy protection capabilities of existing technologies, but also provide important guidance for future privacy protection research in the field of NLP.



§ PRELIMINARIES


Before we delve deeper into our CusText technique, let's first briefly review some fundamental concepts, including ϵ-differential privacy and the exponential mechanism.

Definition 1 (ϵ-differential privacy)
Given a privacy parameter ϵ≥ 0, for all adjacent input pairs x, x' ∈ X, and for every possible output y ∈ Y, a randomized mechanism M satisfies ϵ-differential privacy if it adheres to the following condition:

    [M(x) = y]/[M(x' ) = y]≤ e^ϵ

In this definition, a smaller ϵ indicates a higher level of privacy protection. Theoretically, ϵ-DP ensures that even adversaries with infinite computing power cannot distinguish between the probability distributions of two adjacent inputs, as their probabilities of producing the same output y are closely matched. In the context of Natural Language Processing (NLP), any pair of input tokens that produce the same output set Y are considered adjacent. This paper continues to use this definition for adjacent inputs.

Definition 2 (Exponential Mechanism).
Given a scoring function u: X × Y →ℝ, the exponential mechanism M(X, u, Y) achieves ϵ-differential privacy by randomly selecting an output token y ∈ Y to perturb the input token x ∈ X with a probability proportional to 

    e^ϵ· u(x,y)/2Δ u

Here, u(x, y) represents the score of the output token y for the input token x. Additionally, the sensitivity of u, denoted as Δ u, for the exponential mechanism (EM) is defined by 

    Δ u := max_y ∈ Ymax_x, x' ∈ X| u(x, y) - u(x', y) |


According to the second definition, lower sensitivity makes it statistically more difficult to distinguish the original token from its adjacent tokens. In practice, we may standardize the scoring function u, normalizing its sensitivity Δ u to a fixed value (e.g., 1), so that the selection probability for each output token y for an input token x is solely related to u(x, y), considering that ϵ and Δ u are predetermined, and a larger u(x, y) results in a higher sampling probability.

In an NLP task, we assume each document D = ⟨ R_i ⟩_i=1^m contains m records, and each record R = ⟨ t_j ⟩_j=1^n contains n tokens. We define the task of text sanitization as follows: Given an input document D containing sensitive information, a set of all possible input tokens X, a set of all possible output tokens Y, and a differential privacy mechanism M (e.g., the EM used in this work), it applies the mechanism M to each input token t_j ∈ D, replacing it with an output token t'_j ∈ Y if t_j ∈ X. All tokens after replacement form the sanitized document, i.e., D' = ⟨ R'_i ⟩_i=1^m and R' = ⟨ t'_j ⟩_j=1^n.

Following previous studies <cit.>, we still adopt a semi-honest threat model in the context of local differential privacy. In this model, the data owner only submits sanitized documents to the service provider. However, a malicious service provider may try to extract sensitive information from the received data. We assume that the adversary can only obtain the sanitized text and all algorithms and mechanisms are public and transparent. In addition, we also assume that the adversary has unlimited computing power.




§ METHOD

Our privacy perturbation method is based on the CusText mechanism. The difference is that we use the BERT pre-trained model to assign weights to different words in the same example. Then we average the weights of multiple heads and layers. We remove the weights of CLS and septoken and regularize the weights of other words. Use this weight value to represent the importance of different words. Then we combine the CusText mechanism to perform different degrees of perturbation for our words of different importance.

"CusText" is a tailored text sanitization framework designed to safeguard privacy by substituting every token within a text. It comprises two primary components: firstly, a semantic correlation-based mapping function, fmap, which identifies the appropriate output set for each input token; secondly, a sampling function, fsample, that selects new tokens from this output set using an exponential mechanism.

Unlike traditional SANTEXT methods, CusText enhances the relevance of the output tokens to the original tokens by customizing the output set for each input token, thus improving the utility of the model. The development of the mapping function involves picking tokens from the input set, identifying those that are semantically closest, and creating a mapping. This mapping is then refined by progressively removing the tokens that have been mapped until a complete mapping is achieved or there are insufficient tokens left to continue. This strategy ensures that every input token is paired with at least one neighboring token, preserving the effectiveness of the privacy measures.



Sampling function: The fsample function, which is reliant on the fmap, selects an output tag for each input tag. This selection is governed by an exponential mechanism, and it requires a carefully designed scoring function u to maintain a balance between utility and privacy. The function ensures that the relationship between each input and output tag pair is capped, with pairs that are semantically closer receiving higher scores.

Scoring Function,custext is based on the same similarity function used in mapping schemes,,e.g., Euclidean distance or cosine similarity based on token-vector,representations <cit.>.,In general, all similarity measures can be divided into two categories,,negative and positive,,according to the correlation between the score and semantic proximity.,For example, Euclidean distance and cosine similarity are negative,and positive correlation measures, respectively, because the smaller the Euclidean distance,and the larger the cosine value between two vectors,,means that the semantic proximity of their corresponding tokens is higher.,Next, we will design scoring functions for these two types of similarity,measurements.

The following is our own perturbation method based on words of different importance. Our method mainly uses the pre-extracted words of different importance as our sensitive word list, and then uses the custext method to perturb these sensitive word lists.



Aggressive mechanism.
When we select the important vocabulary list, if we adopt an aggressive mechanism, we can perturb all the words in the sensitive vocabulary list without difference, but this may have a greater impact on the original semantics of the text, because the same noun or the same verb will be perturbed into different words, which will cause the text semantics to be incoherent. The result for short text may be less than the effect on long text.

Conservative mechanism.
When the same sensitive word appears multiple times in a sample, we give it the same perturbation result. This is a conservative mechanism and may be easier to attack. But it is possible to give the same nouns the same perturbation in the content of long texts. In this way, the relationship between words such as subject and predicate can be better preserved, and its semantic structure can be preserved. It is possible to protect sensitive information while still having better semantic information and text information.
The above two mechanisms can be used to process different categories of text data, and can be freely selected as needed. Combined with our selection mechanism for words of different degrees of importance, the text can be protected more flexibly to better achieve a balance between privacy and utility.



§ EXPERIMENT
.
Experimental Setup,

5.1 Experimental Setup
Following <cit.>
We selected two datasets from the GLUE benchmark <cit.> in our experiments, both of which contain
In our experimental section, we aim to demonstrate the efficacy of using attention mechanism parameters to represent the importance of different words within a sample. This section is divided into two parts, each utilizing the public datasets SST-2 and QNLI to validate our method.

Datasets Description:

    
  * SST-2: A widely-used movie review dataset for sentiment classification, consisting of 67,000 training samples and 1,800 test samples. The evaluation metric is accuracy.
    
  * QNLI: A dataset for sentence pair classification with 105,000 training samples and 5,200 test samples. Accuracy is also used as the evaluation metric here.


In our approach, for both the SST-2 and QNLI datasets, we first identify the most and least important words, quantified as the top and bottom 10%, 20%, 30%, 40%, 50%, and 60% based on the attention scores. These words are considered as the sensitive words that need to be perturbed. We record the number of words actually perturbed during training and compare it under similar total perturbation conditions to gauge the effectiveness of our method.
We use the vocabulary from CounterFitting in GloVe, and apply both Euclidean distance and cosine similarity as measures for comparing GloVe vectors. The sensitive word list is derived from the probabilities associated with different words in the pre-trained model.
For each downstream task, we set the maximum sequence length to 128 and limit the training to 3 epochs. On both SST-2 and QNLI datasets, the batch size is set to 64. We use  as the pre-trained model with an increased learning rate of 2 × 10^-5. The experiments are conducted on an A100 GPU.

The second part of our experimental analysis focuses on demonstrating the effectiveness of our approach. In this phase, we perturb words of varying degrees of importance—specifically, 5%, 10%, and 20% of the words determined by our quantifier. We then evaluate both the privacy and effectiveness of the perturbed datasets using several established mechanisms.


    
  * Evaluation Mechanisms: We apply various metrics to assess the privacy levels and the utility of the datasets after perturbation.
    
  * Data Perturbation: We methodically perturb the words identified as having high, medium, and low importance to measure the impact on the dataset’s utility and privacy.
    
  * Analysis of Important Words: This method also allows us to count and calculate the distribution of words based on their importance. We identify and examine some relatively high-importance words, observe the categories they belong to, and analyze their patterns.


This structured evaluation helps in understanding how different levels of perturbation affect the privacy-security balance and the overall effectiveness of the sensitive data we intend to protect.




 §.§ Experiment Result

Below are some of my experimental results when ϵ equals to 3.












 §.§ result analysis
For the perturbation of data with different importance, we conducted experiments on the SST-2 and QNLI datasets. For fair comparison in the future, we chose Glove as the token embedding and controlled other variables to be the same. Table 1 shows the results of perturbing words of different importance on the SST-2 dataset while keeping the training set unchanged. For the same test set, words of different importance are perturbed while keeping ϵ = 3 unchanged. As can be seen from the figure, when the test set data is perturbed with basically the same amount of data, the result of perturbing more important words is worse than that of perturbing less important words, which also proves that our vocabulary extraction method is correct. Figure 2 shows the results of perturbing the training data and test data at the same time. The results show that when perturbing the same number of words of different importance, perturbing more important words has a greater impact on the results, which also proves that our extraction strategy is correct. When we make a horizontal comparison, we find that when we use the perturbed training set for training, the matching effect with the test set is better, which also reflects the effectiveness of our method for words of different importance to a certain extent. When we observe the results of the QNLI dataset, we can also draw the above conclusions. Therefore, our Transformer-based extraction method is effective. When we perform differential privacy on the text, we can selectively perturb words of different importance. Of course, this method can also be used as a screening mechanism to help us narrow the search scope of keywords and privacy words. Combined with other named entity recognition and LLM reasoning methods, it can help us find more effective keywords faster. This will be a general method.

Conservative method, when we adopt a conservative strategy, that is, when we keep the same perturbation results for the same words in the same sample, the results are as follows. Here we mainly analyze the results of the guard strategy for the top 10, 20, 30, 40, and 50 emphasized words of qnli (long text length, with a greater possibility of the same vocabulary). It can be observed that when we consider adopting the guard strategy, the results of the experiment will be significantly improved. Therefore, we can use the guard strategy in the relatively long policy text protection process, which can better maintain semantic coherence.

Token reasoning attacks and query attacks are carried out on the perturbed text to test the effectiveness of our extraction of data of different importance and its relevance to privacy. Using a pre-trained BERT model can help infer the possibility of recovering the original text from the purified text. By replacing each token in the purified text with the "[MASK]" token and inputting it into the BERT model, we can get the model's predicted output for "[MASK]", which is the inferred original token. If the predicted output is the same as the token of the original input, we consider the attack attempt to be successful. By calculating the success rate of all such attacks (rmask), we can measure the privacy protection of the text, which is 1-rmask. Because our algorithm is based on the custext algorithm and has not been modified to the original algorithm, its effect is the same as custext.

Importance vocabulary analysis When we use chatgpt4 to analyze the words of different importance we extracted, we find that the more important words are often those nouns, pronouns, punctuation marks, etc. This is the same as the more important words in a sentence we understand. However, when we use GPT4 and our more important words to reconstruct the zero-shot sentence, the reconstructed sentence is very different from our original sentence. Therefore, our method does not perform well under unguided reconstruction. This method may be more suitable for identifying important words.



§ CONCLUSION AND LIMITATION

Conclusion: This method proves that we can reflect the importance of different words in different sentences through multiple layers of Transformers and the attention weights between them, but more supplementary experiments are needed. Moreover, when we apply this method to long text data, our accuracy will be biased due to the limitation of the maximum length of Transformer and the long text length. This requires us to combine some other models and find a way to obtain longer length data at the same time. We need to do more work on this basis to improve its performance. We can do more experiments and research on this basis in combination with LLM.



§ FUTURE WORK

With the recent emergence and development of LLM, I think we can combine the large oracle model with the discovery of sensitive data. Combined with prompts, LLM can identify important and sensitive information in the text. And we can combine LLM with this method to filter sensitive information in the text except for specific categories, because some other information in the text that is not classified may also contain some critical sensitive information. This is a direction worth exploring.


apalike 


