Sentence-level Privacy for Document Embeddings

Casey Meehan, Khalil Mrini, Kamalika Chaudhuri

Introduction

Language models have now become ubiquitous in NLP Devlin et al. (2019); Liu et al. (2019b); Alsentzer et al. (2019), pushing the state of the art in a variety of tasks Strubell et al. (2018); Liu et al. (2019a); Mrini et al. (2021). While language models capture meaning and various linguistic properties of text Jawahar et al. (2019); Yenicelik et al. (2020), an individual’s written text can include highly sensitive information. Even if such details are not needed or used, sensitive information has been found to be vulnerable and detectable to attacks Pan et al. (2020); Abdalla et al. (2020); Carlini et al. (2020). Reconstruction attacks Xie and Hong (2021) have even successfully broken through private learning schemes that rely on encryption-type methods Huang et al. (2020).

As of now, there is no broad agreement on what constitutes good privacy for natural language Kairouz et al. (2019). Huang et al. (2020) argue that different applications and models require different privacy definitions. Several emerging works propose to apply Metric Differential Privacy Alvim et al. (2018) at the word level Feyisetan et al. (2019); Feyisetan and Kasiviswanathan (2021); Carvalho et al. (2021); Qu et al. (2021); Yue et al. (2021); Xu et al. (2021) . They propose to add noise to word embeddings, such that they are indistinguishable from their nearest neighbours.

At the document level, however, the above definition has two areas for improvement. First, it may not offer the level of privacy desired. Having each word indistinguishable with similar words may not hide higher level concepts in the document, and may not be satisfactory for many users. Second, it may not be very interpretable or easy to communicate to end-users, since the privacy definition relies fundamentally on the choice of embedding model to determine which words are indistinguishable with a given word. This may not be clear and precise enough for end-users to grasp.

In this work, we propose a new privacy definition for documents: sentence privacy. This guarantee is both strong and interpretable: any sentence in a document must be indistinguishable with any other sentence. A document embedding is sentence-private if we can replace any single sentence in the document and have a similar probability of producing the same embedding. As such, the embedding only stores limited information unique to any given sentence. This definition is easy to communicate and strictly stronger than word-level definitions, as modifying a sentence can be changing one word.

Although this definition is strong, we are able to produce unsupervised, general embeddings of documents that are useful for downstream tasks like sentiment analysis and topic classification. To achieve this we propose a novel privacy mechanism, deepcandidate, which privately samples a high-dimensional embedding from a preselected set of candidate embeddings derived from public, non-private data. deepcandidate works by first pre-tuning a sentence encoder on public data such that semantically different document embeddings are far apart from each other. Then, we approximate each candidate’s Tukey Depth within the private documents’ sentence embeddings. Deeper candidates are the most likely to be sampled to represent the private document. We evaluate deepcandidate on three illustrative datasets, and show that these unsupervised private embeddings are useful for both sentiment analysis and topic classification as compared to baselines.

In summary, this work makes the following contributions to the language privacy literature:

A new, strong, and interpretable privacy definition that offers complete indistinguishability to each sentence in a document.

A novel, unsupervised embedding technique, deepcandidate, to generate sentence-private document embeddings.

An empirical assessment of deepcandidate, demonstrating its advantage over baselines, delivering strong privacy and utility.

Background and Related Work

We denote a ‘document’ as a sequence of sentences. Let s∈Ss\in\mathcal{S} be any finite-length sentence. Then, the space of all documents is X=S∗\mathcal{X}=\mathcal{S}^{*} and document x∈Xx\in\mathcal{X} is written as x=(s1,s2,…,sk)x=(s_{1},s_{2},\dots,s_{k}) for any non-negative integer kk of sentences. In this work, we focus on cohesive documents of sentences written together like reviews or emails, but our methods and guarantees apply to any sequence of sentences, such as a collection of messages written by an individual over some period of time.

1 Differential Privacy

The above privacy notion is inspired by Differential Privacy (DP) Dwork (2006). It guarantees that — whether an individual participates (dataset DD) or not (dataset D′D^{\prime}) — the probability of any output only chances by a constant factor.

Given any pair of datasets D,D′∈DD,D^{\prime}\in\mathcal{D} that differ only in the information of a single individual, we say that the mechanism A:D→O\mathcal{A}:\mathcal{D}\rightarrow\mathcal{O}, satisfies ϵ\epsilon-DP if

Note that we take probability over the randomness of the mechanism A\mathcal{A} only, not the data distribution. DP has several nice properties that make it easy to work with including closure under post-processing, an additive privacy budget (composition), and closure under group privacy guarantees (guarantees to a subset of multiple participants). See Dwork et al. 2014 for more details.

The exponential mechanism AExp:D→O\mathcal{A}_{Exp}:\mathcal{D}\rightarrow\mathcal{O} is a randomized algorithm with output distribution

2 Related Work

Previous work has demonstrated that NLP models and embeddings are vulnerable to reconstruction attacks Carlini et al. (2020); Abdalla et al. (2020); Pan et al. (2020). In response there have been various efforts to design privacy-preserving techniques and definitions across NLP tasks. A line of work focuses on how to make NLP model training satisfy DP Kerrigan et al. (2020); Bagdasaryan et al. (2019). This is distinct from our work in that it satisfies central DP – where data is first aggregated non-privately and then privacy preserving algorithms (i.e. training) are run on that data. We model this work of the local version of DP Dwork et al. (2006), wherein each individual’s data is made private before centralizing. Our definition guarantees privacy to a single document as opposed to a single individual.

A line of work more comparable to our approach makes documents locally private by generating a randomized version of a document that satisfies some formal privacy definition. As with the private embedding of our work, this generates locally private representation of a given document xx. The overwhelming majority of these methods satisfy an instance of Metric-DP Alvim et al. (2018) at the word level Feyisetan et al. (2019); Feyisetan and Kasiviswanathan (2021); Carvalho et al. (2021); Qu et al. (2021); Yue et al. (2021); Xu et al. (2021). As discussed in the introduction, this guarantees that a document xx is indistinguishable with any other document x′x^{\prime} produced by swapping a single word in xx with a similar word. Two words are ‘similar’ if they are close in the word embeddings space (e.g. GloVe). This guarantee is strictly weaker than our proposed definition, SentDP, which offers indistinguishability to any two documents that differ in an entire sentence.

Privacy-preserving embeddings.

Sentence-level Privacy

We now introduce our simple, strong privacy definition, along with concepts we use to satisfy it.

In this work, we adopt the local notion of DP Dwork et al. (2006), wherein each individual’s data is guaranteed privacy locally before being reported and centralized. Our mechanism M\mathcal{M} receives a single document from a single individual, x∈Xx\in\mathcal{X}. We require that M\mathcal{M} provides indistinguishability between documents x,x′x,x^{\prime} differing in one sentence.

Given any pair of documents x,x′∈Xx,x^{\prime}\in\mathcal{X} that differ only in one sentence, we say that a mechanism M:X→O\mathcal{M}:\mathcal{X}\rightarrow\mathcal{O} satisfies ϵ\epsilon-SentDP if

2 Sentence Mean Embeddings

maintains significant information unique to the document and is useful for downstream tasks like classification and sentiment analysis.

We call g‾(x)\overline{g}(x) the document embedding since it summarizes the information in document xx. While there exist other definitions of document embeddings Yang et al. (2016); Thongtan and Phienthrakul (2019); Bianchi et al. (2020), we decide to use averaging as it is a simple and established embedding technique Bojanowski et al. (2017); Gupta et al. (2019); Li et al. (2020).

3 Tukey Depth

Depth is a concept in robust statistics used to describe how central a point is to a distribution. We borrow the definition proposed by Tukey (1975):

In other words, take the hyperplane orthogonal to vector ww, hwh_{w}, that passes through point yy. Let P1wP_{1}^{w} be the probability under PP that a point lands on one side of hwh_{w} and let P2wP_{2}^{w} be the probability that a point lands on the other side, so P1w+P2w=1P_{1}^{w}+P_{2}^{w}=1. yy is considered deep if min⁡(P1w,P2w)\min(P_{1}^{w},P_{2}^{w}) is close to a half for all vectors ww (and thus all hh passing through yy). The Tukey Median of distribution PP, TMED(P)\text{T}_{\text{MED}}(P), is the set of all points with maximal Tukey Depth,

We only access the distribution PP through a finite sample of i.i.d. points, Y={y1,y2,…,yn}Y=\{y_{1},y_{2},\dots,y_{n}\}. The Tukey Depth w.r.t. YY is given by

and the median, TMED(Y)\text{T}_{\text{MED}}(Y), maximizes the depth and is at most half the size of our sample \big{\lfloor}\frac{n}{2}\big{\rfloor}.

Generally, finding a point in TMED(Y)\text{T}_{\text{MED}}(Y) is hard; SOTA algorithms have an exponential dependency in dimension Chan (2004), which is a non-starter when working with high-dimensional embeddings. However, there are efficient approximations which we will take advantage of.

deepcandidate

While useful and general, the document embedding g‾(x)\overline{g}(x) does not satisfy SentDP. We now turn to describing our privacy-preserving technique, deepcandidate, which generates general, ϵ\epsilon-SentDP document embeddings that preserve relevant information in g‾(x)\overline{g}(x), and are useful for downstream tasks. To understand the nontrivial nature of this problem, we first analyze why the simplest, straightfoward approaches are insufficient.

Our method has three pillars: (1) sampling from a candidate set of public, non-private document embeddings to represent the private document, (2) using the Tukey median to approximate the document embedding, and (3) pre-training the sentence encoder, GG, to produce relevant candidates with high Tukey depth for private document xx.

1 Taking advantage of public data: sampling from candidates

and denote the corresponding distribution over fif_{i} as g‾(μ)\overline{g}(\mu). By selecting candidate documents that are similar in nature to the private document xx, we inject an advantageous inductive bias into our mechanism, which is critical to satisfy strong privacy while preserving information relevant to xx.

2 Approximating the document embedding: The Tukey Median

We now propose a novel mechanism MTD\mathcal{M}_{\text{TD}}, which approximates g‾(x)\overline{g}(x) by sampling a candidate embedding from FF. MTD\mathcal{M}_{\text{TD}} works by concentrating probability on candidates with high Tukey Depth w.r.t. the set of sentence embeddings Sx={G(si):si∈x}S_{x}=\{G(s_{i}):s_{i}\in x\}. We model sentences sis_{i} from document xx as i.i.d. draws from distribution νx\nu_{x}. Then, SxS_{x} is kk draws from g(νx)g(\nu_{x}), the distribution of sentences from νx\nu_{x} passing through GG. Deep points are a good approximation of the mean under light assumptions. If g(νx)g(\nu_{x}) belongs to the set of halfspace-symmetric distributions (including all elliptic distributions e.g. Gaussians), we know that its mean lies in the Tukey Median Zhu et al. (2020).

Formally, MTD\mathcal{M}_{\text{TD}} is an instance of the exponential mechanism (Definition 2.2), and is defined by its utility function. We set the utility of a candidate document embedding fi∈Ff_{i}\in F to be an approximation of its depth w.r.t. sentence embeddings SxS_{x},

The approximation TD^Sx\widehat{\text{TD}}_{S_{x}}, which we detail in the Appendix, is necessary for computational efficiency. If the utility of fif_{i} is high, we call it a ‘deep candidate’ for sentence embeddings SxS_{x}.

The more candidates sampled (higher mm), the higher the probability that at least one has high depth. Without privacy, we could report the deepest candidate, z=arg max fi∈FTD^Sx(fi)z=\underset{f_{i}\in F}{\text{arg max }}\widehat{\text{TD}}_{S_{x}}(f_{i}). However, when preserving privacy with MTD\mathcal{M}_{\text{TD}}, increasing mm has diminishing returns. To see this, fix a set of sentence embeddings SxS_{x} for document xx and the i.i.d. distribution over candidate embeddings fi∼g‾(μ)f_{i}\sim\overline{g}(\mu). This induces a multinomial distribution over depth,

where randomness is taken over draws of fif_{i}.

For candidate set FF and sentence embeddings SxS_{x}, the probability of MTD\mathcal{M}_{\text{TD}}’s selected candidate, zz, having (approximated) depth j∗j^{*} is given by

where aj(x)a_{j}(x) is the fraction of candidates in FF with depth jj w.r.t. the sentence embeddings of document xx, SxS_{x}. For mm sufficiently large, aj(x)a_{j}(x) concentrates around uj(x)u_{j}(x), so further increasing mm does not increase the probability of MTD\mathcal{M}_{\text{TD}} sampling a deep candidate.

For numerical intuition, suppose m=5000m=5000 (as in our experiments), ≥b\geq b candidates have depth ≥j∗\geq j^{*}, and all other candidates have depth 0, MTD\mathcal{M}_{\text{TD}} will sample one of these deep candidates w.p. ≥0.95\geq 0.95 under the settings in Table 1.

For low ϵ<10\epsilon<10 (high privacy), about 1% of candidates need to have high depth (≥3)(\geq 3) in order to be reliably sampled. Note that this is only possible for documents with ≥6\geq 6 sentences. For higher ϵ≥10\epsilon\geq 10, MTD\mathcal{M}_{\text{TD}} will reliably sample low depth candidates even if there are only a few.

From these remarks we draw two insights on how deepcandidate can achieve high utility. (1) More sentences A higher kk enables greater depth, and thus a higher probability of sampling deep candidates with privacy. We explore this effect in our experiments. (2) Tuned encoder By tuning the sentence encoder GG for a given domain, we can modify the distribution over document embeddings g‾(μ)\overline{g}(\mu) and sentence embeddings g(νx)g(\nu_{x}) to encourage deep candidates (high probability uju_{j} for deep jj) that are relevant to document xx.

3 Taking advantage of structure: cluster-preserving embeddings

4 Sampling Algorithm

The final component of deepcandidate is computing the approximate depth of a candidate for use as utility in the exponential mechanism as in Eq. (3). We use a version of the approximation algorithm proposed in Gilad-Bachrach and Burges 2012. Intuitively, our algorithm computes the one-dimensional depth of each fif_{i} among xx’s sentence embeddings SxS_{x} on each of pp random projections. The approximate depth of fif_{i} is then its lowest depth across the pp projections. We are guaranteed that TD^Sx(fi)≥TDSx(fi)\widehat{\text{TD}}_{S_{x}}(f_{i})\geq\text{TD}_{S_{x}}(f_{i}). Due to space constraints, we leave the detailed description of the algorithm for the Appendix.

MTD\mathcal{M}_{\text{TD}} satisfies ϵ\epsilon-Sentence Privacy

Proof follows from the fact that TD^Sx(fi)\widehat{\text{TD}}_{S_{x}}(f_{i}) has bounded sensitivity (changing one sentence can only change depth of fif_{i} by one). We expand on this, too, in the Appendix.

Experiments

We produce private, general embeddings of documents from three English-language datasets:

Good Reads Wan and McAuley (2018) 60k book reviews from four categories: fantasy, history, romance, and childrens literature. Train-48k | Val-8k | Test-4k

20 News Groups Lang (1995) 11239 correspondences from 20 different affinity groups. Due to similarity between several groups (e.g. comp.os.ms-windows.misc and comp.sys.ibm.pc.hardware), the dataset is partitioned into nine categories. Train-6743k | Val-2247k | Test-2249k

IMDB Maas et al. (2011) 29k movie reviews from the IMDB database, each labeled as a positive or negative review. Train-23k | Val-2k | Test-4k

To evaluate utility of these unsupervised, private embeddings, we check if they are predictive of document properties. For the Good Reads and 20 News Groups datasets, we evaluate how useful the embeddings are for topic classification. For IMDB we evaluate how useful the embeddings are for sentiment analysis (positive or negative review). Our metric for performance is test-set macro F1F_{1} score.

2 Training Details & Setup

The candidate set FF consists of 5k document embeddings from the training set, each containing at least 8 sentences. To train G′G^{\prime}, we find nc=50n_{c}=50 clusters with kk-means. We train a classifier Cdc=C_{\text{dc}}= MLPr\textbf{MLP}^{r} on document embeddings g′(x)g^{\prime}(x) to predict class, where rr is the number of classes (topics or sentiments).

3 Baselines

We compare the performance of deepcandidate with 4 baselines: Non-private, Truncation, Word-level Metric-DP, and Random Guesser.

Non-private: This demonstrates the usefulness of non-private sentence-mean document embeddings g‾(x)\overline{g}(x). We generate g‾(x)\overline{g}(x) for every document using SBERT, and then train a classifier Cnonpriv=C_{\text{nonpriv}}= MLPr\textbf{MLP}^{r} to predict xx’s label from g‾(x)\overline{g}(x).

Word Metric-DP (MDP): The method from Feyisetan et al. 2019 satisfies ϵ\epsilon-word-level metric DP by randomizing words. We implement MDP to produce a randomized document x′x^{\prime}, compute g‾(x′)\overline{g}(x^{\prime}) with SBERT, and predict class using CnonprivC_{\text{nonpriv}}.

Random Guess: To set a bottom-line, we show the theoretical performance of a random guesser only knowing the distribution of labels.

4 Results & Discussion

How does performance change with privacy parameter ϵ\epsilon? This is addressed in Figures 4(a) to 4(c). Here, we observe how the test set macro F1F_{1} score changes with privacy parameter ϵ\epsilon (a lower ϵ\epsilon offers stronger privacy). Generally speaking, for local differential privacy, ϵ<10\epsilon<10 is taken to be a strong privacy regime, 10≤ϵ<2010\leq\epsilon<20 is moderate privacy, and ϵ≥25\epsilon\geq 25 is weak privacy. The truncation baseline mechanism does increase accuracy with increasing ϵ\epsilon, but never performs much better than the random guesser. This is to be expected with high dimension embeddings, since the standard deviation of noise added increases linearly with dimension.

The word-level MDP mechanism performs significantly better than truncation, achieving relatively good performance for ϵ≥30\epsilon\geq 30. There are two significant caveats, however. First, is the privacy definition: as discussed in the Introduction, for the same ϵ\epsilon, word-level MDP is strictly weaker than SentDP. The second caveat is the level of ϵ\epsilon at which privacy is achieved. Despite a weaker privacy definition, the MDP mechanism does not achieve competitive performance until the weak-privacy regime of ϵ\epsilon. We suspect this is due to two reasons. First, is the fact that the MDP mechanism does not take advantage of contextual information in each sentence as our technique does; randomizing each word independently does not use higher level linguistic information. Second, is the fact that the MDP mechanism does not use domain-specific knowledge as our mechanism does with use of relevant candidates and domain specific sentence encodings.

In comparison, deepcandidate offers strong utility across tasks and datasets for relatively low values of ϵ\epsilon, even into the strong privacy regime. Beyond ϵ=25\epsilon=25, the performance of deepcandidate tends to max out, approximately 10-15% below the non-private approach. This is due to the fact that deepcandidate offers a noisy version of an approximation of the document embedding g‾(x)\overline{g}(x) – it cannot perform any better than deterministically selecting the deepest candidate, and even this candidate may be a poor representative of xx. We consider this room for improvement, since there are potentially many other ways to tune G′G^{\prime} and select the candidate pool FF such that deep candidates are nearly always good representatives of a given document xx.

How does performance change with the number of sentences kk? This is addressed in Figures 4(d) to 4(f). We limit the test set to those documents with kk in the listed range on the x-axis. We set ϵ=10\epsilon=10, the limit of the strong privacy regime. Neither baseline offers performance above that of the random guesser at this value of ϵ\epsilon. deepcandidate produces precisely the performance we expect to see: documents with more sentences result in sampling higher quality candidates, confirming the insights of Section 4.2. Across datasets and tasks, documents with more than 10-15 sentences tend to have high quality embeddings.

Conclusions and Future Work

We introduce a strong and interpretable local privacy guarantee for documents, SentDP, along with deepcandidate, a technique that combines principles from NLP and robust statistics to generate general ϵ\epsilon-SentDP embeddings. Our experiments confirm that such methods can outperform existing approaches even with with more relaxed privacy guarantees. Previous methods have argued that it is “virtually impossible” to satisfy pure local DP Feyisetan et al. (2019); Feyisetan and Kasiviswanathan (2021) at the word level while capturing linguistic semantics. Our work appears to refute this notion at least at the document level.

To follow up, we plan to explore other approaches (apart from kk-means) of capturing the structure of the embedding distribution g‾(μ)\overline{g}(\mu) to encourage better candidate selection. We also plan to experiment with decoding private embeddings back to documents by using novel candidates produced by a generative model trained on FF.

Acknowledgements

KC and CM would like to thank ONR under N00014-20-1-2334. KM gratefully acknowledges funding from an Amazon Research Award and Adobe Unrestricted Research Gifts. We would would also like to thank our reviewers for their insightful feedback.

References

Appendix A Appendix

We now describe in detail our instance of the exponential mechanism MTD\mathcal{M}_{\text{TD}}. Recall from Definition 2.2 that the exponential mechanism samples candidate fi∈Ff_{i}\in F with probability

Thus, MTD\mathcal{M}_{\text{TD}} is fully defined by its utility function, which, as listed in Equation (3), is approximate Tukey Depth,

We now describe our approximation algorithm of Tukey Depth TD^Sx(fi)\widehat{\text{TD}}_{S_{x}}(f_{i}), which is an adaptation of the general median hypothesis algorithm proposed by Gilad-Bachrach and Burges (2012).

Note that we can precompute the projections on line 10. The runtime is O(mkp)O(mkp): for each of mm candidates and on each of pp projections, we need to compute the scalar difference with kk sentence embeddings. Sampling from the multinomial distribution defined by PFP_{F} then takes O(m)O(m) time.

Additionally note from lines 13 and 15 that utility has a maximum of 0 and a minimum of −k2-\frac{k}{2}, which is a semantic change from the main paper where maximum utility is k2\frac{k}{2} and minimum is 0.

A.2 Proof of Privacy

Theorem 4.1 MTD\mathcal{M}_{\text{TD}} satisfies ϵ\epsilon-Sentence Privacy

It is sufficient to show that the sensitivity,

Let us expand the above expression using the terms in Algorithm 1.

The last step follows from the fact that ∣hj(x,fi)−hj(x′,fi)∣≤1|h_{j}(x,f_{i})-h_{j}(x^{\prime},f_{i})|\leq 1 for all j∈[p]j\in[p]. In other words, by modifying a single sentence embedding, we can only change the number of embeddings greater than fijf_{i}^{j} on projection jj by 1. So, the distance of hj(x,fi)h_{j}(x,f_{i}) from k2\frac{k}{2} can only change by 1 on each projection. In the ‘worst case’, the distance \big{|}h_{j}(x,f_{i})-\frac{k}{2}\big{|} reduces by 1 on every projection vjv_{j}. Even then, the minimum distance from k2\frac{k}{2} across projections (the worst case depth) can only change by 1, giving us a sensitivity of 1. ∎

A.3 Experimental Details

Here, we provide an extended, detailed version of section 5.

For our non-private baseline, we demonstrate the usefulness of sentence-mean document embeddings. First, we generate the document embeddings g‾(xi)\overline{g}(x_{i}) for each training, validation, and test set document using SBERT, GG. We then train a classifier Cnonpriv=C_{\text{nonpriv}}= MLPr\textbf{MLP}^{r} to predict each document’s topic or sentiment, where rr is the number of classes. The number of training epochs is determined with the validation set.

deepcandidate:

We first collect the candidate set FF by sampling 5k document embeddings from the subset of the training set containing at least 8 sentences. We run kk-means with nc=50n_{c}=50 cluster centers, and label each training set document embedding ti∈TGt_{i}\in T_{G} with its cluster. The sentence recoder, H=H= MLP768\textbf{MLP}^{768} is trained on the training set along with the linear model LL with the Adam optimizer and cross-entropy loss. For a given document xx, its sentence embeddings SxS_{x} are passed through HH, averaged together, and then passed to LL to predict xx’s cluster. LL’s loss is then back-propagated through HH. A classifier Cdc=C_{\text{dc}}= MLPr\textbf{MLP}^{r} is trained in parallel using a separate instance of the Adam optimizer to predict class from the recoded embeddings, where rr is the number of classes (topics or sentiments). The number of training epochs is determined using the validation set. At test time, (generating private embeddings using MTD\mathcal{M}_{\text{TD}}), the optimal number of projections pp is empirically chosen for each ϵ\epsilon using the validation set.

Truncation:

The truncation baseline Li and Clifton (2021) requires first constraining the embedding instance space. We do so by computing the 75% median interval on each of the 768 dimensions of training document embeddings TGT_{G}. Sentence embeddings are truncated at each dimension to lie in this box. In order to account for this distribution shift, a new classifier Ctrunc=C_{\text{trunc}}= MLPr\textbf{MLP}^{r} is trained on truncated mean embeddings to predict class. The number of epochs is determined with the validation set. At test time, a document’s sentence embeddings SxS_{x} are truncated and averaged. We then add Laplace noise to each dimension with scale factor 768wkϵ\frac{768w}{k\epsilon}, where ww is the width of the box on that dimension (sensitivity in DP terms). Note that the standard deviation of noise added is inversely proportional to the number of sentences in the document, due to the averaging operation reducing sensitivity.

Word Metric-DP:

Our next baseline satisfies ϵ\epsilon-word-level metric DP and is adopted from Feyisetan et al. (2019). The corresponding mechanism MDP:X→X\text{MDP}:\mathcal{X}\rightarrow\mathcal{X} takes as input a document xx and returns a private version, x′x^{\prime}, by randomizing each word individually. For comparison, we generate document embeddings by first randomizing the document x′=MDP(x)x^{\prime}=\text{MDP}(x) as prescribed by Feyisetan et al. (2019), and then computing its document embedding g‾(x′)\overline{g}(x^{\prime}) using SBERT. At test time, we classify the word-private document embedding using CnonprivC_{\text{nonpriv}}.

Random Guess:

To set a bottom-line, we show the theoretical performance of a random guesser. The guesser chooses class ii with probability qiq_{i} equal to the fraction of ii labels in the training set. The performance is then given by ∑i=1rqi2\sum_{i=1}^{r}q_{i}^{2}.

A.4 Reproducability Details

We plan to publish a repo of code used to generate the exact figures in this paper (random seeds have been set) with the final version. Since we do not train the BERT base model GG, our algorithms and training require relatively little computational resouces. Our system includes a single Nvidia GeForce RTX 2080 GPU and a single Intel i9 core. All of our models complete an epoch training on all datasets in less than one minute. We never do more than 20 epochs of training. All of our classifier models train (including linear model) have less than 11 million parameters. The relatively low amount of parameters is due to the fact that we freeze the underlying language model. The primary hyperparameter tuned is the number of projections pp. We take the argmax value on the validation set between 10 and 100 projections. We repeat this for each value of ϵ\epsilon.

For all datasets, we limit ourselves to documents with at least 2 sentences.

IMDB: This dataset has pre-defined train/test splits. We use the entire training set and form the test set by randomly sampling 4,000 from the test set provided. We do this for efficiency in computing the Metric-DP baseline, which is the slowest of all algorithms performed. Since the Metric-DP baseline randomizes first, we cannot precompute the sentence embeddings G(si)G(s_{i}) – we need to compute the sentence embeddings every single time we randomize. Since we randomize for each sentence of each document at each ϵ\epsilon and each kk over 5 trials – this takes a considerable amount of time.

Good Reads: This dataset as provided is quite large. We randomly sample 15000 documents from each of 4 classes, and split them into 12K training examples, 2K validation examples, and 1K test examples per class.

20 News Groups: We preprocess this dataset to remove all header information, which may more directly tell information about document class, and only provide the model with the sentences from the main body. We use the entire dataset, and form the Train/Val/Test splits by random sampling.