Feature Hashing for Large Scale Multitask Learning

Kilian Weinberger, Anirban Dasgupta, Josh Attenberg, John Langford, Alex Smola

Introduction

Kernel methods use inner products as the basic tool for comparisons between objects. That is, given objects x1,…,xn∈Xx_{1},\dots,x_{n}\in\mathcal{X} for some domain X\mathcal{X}, they rely on

to compare the features ϕ(xi)\phi(x_{i}) of xix_{i} and ϕ(xj)\phi(x_{j}) of xjx_{j} respectively.

Eq. (1) is often famously referred to as the kernel-trick. It allows the use of inner products between very high dimensional feature vectors ϕ(xi)\phi(x_{i}) and ϕ(xj)\phi(x_{j}) implicitly through the definition of a positive semi-definite kernel matrix kk without ever having to compute a vector ϕ(xi)\phi(x_{i}) directly. This can be particularly powerful in classification settings where the original input representation has a non-linear decision boundary. Often, linear separability can be achieved in a high dimensional feature space ϕ(xi)\phi(x_{i}).

In practice, for example in text classification, researchers frequently encounter the opposite problem: the original input space is almost linearly separable (often because of the existence of handcrafted non-linear features), yet, the training set may be prohibitively large in size and very high dimensional. In such a case, there is no need to map the input vectors into a higher dimensional feature space. Instead, limited memory makes storing a kernel matrix infeasible.

To our knowledge, we are the first to provide exponential tail bounds on the canonical distortion of these hashed inner products. We also show that the hashing-trick can be particularly powerful in multi-task learning scenarios where the original feature spaces are the cross-product of the data, X\mathcal{X}, and the set of tasks, UU. We show that one can use different hash functions for each task ϕ1,…,ϕ∣U∣\phi_{1},\dots,\phi_{|U|} to map the data into one joint space with little interference.

While many potential applications exist for the hashing-trick, as a particular case study we focus on collaborative email spam filtering. In this scenario, hundreds of thousands of users collectively label emails as spam or not-spam, and each user expects a personalized classifier that reflects their particular preferences. Here, the set of tasks, UU, is the number of email users (this can be very large for open systems such as Yahoo Mail™or Gmail™), and the feature space spans the union of vocabularies in multitudes of languages.

This paper makes four main contributions: 1. In section 2 we introduce specialized hash functions with unbiased inner-products that are directly applicable to a large variety of kernel-methods. 2. In section 3 we provide exponential tail bounds that help explain why hashed feature vectors have repeatedly lead to, at times surprisingly, strong empirical results. 3. Also in section 3 we show that the interference between independently hashed subspaces is negligible with high probability, which allows large-scale multi-task learning in a very compressed space. 4. In section 5 we introduce collaborative email-spam filtering as a novel application for hash representations and provide experimental results on large-scale real-world spam data sets.

Hash Functions

We introduce a variant on the hash kernel proposed by (Shietal09). This scheme is modified through the introduction of a signed sum of hashed features whereas the original hash kernels use an unsigned sum. This modification leads to an unbiased estimate, which we demonstrate and further utilize in the following section.

Usually, we abbreviate the notation ϕ(h,ξ)(⋅)\phi^{(h,\xi)}(\cdot) by just ϕ(⋅)\phi(\cdot). Two hash functions ϕ\phi and ϕ′\phi^{\prime} are different when ϕ=ϕ(h,ξ)\phi=\phi^{(h,\xi)} and ϕ′=ϕ(h′,ξ′)\phi^{\prime}=\phi^{(h^{\prime},\xi^{\prime})} such that either h′≠hh^{\prime}\neq h or ξ≠ξ′\xi\neq\xi^{\prime}. The purpose of the binary hash ξ\xi is to remove the bias inherent in the hash kernel of (Shietal09).

In a multi-task setting, we obtain instances in combination with tasks, (x,u)∈X×U(x,u)\in\mathcal{X}\times U. We can naturally extend our definition 1 to hash pairs, and will write ϕu(x)=ϕ(x,u)\phi_{u}(x)=\phi(x,u).

Analysis

The following section is dedicated to theoretical analysis of hash kernels and their applications. In this sense, the present paper continues where (Shietal09) falls short: we prove exponential tail bounds. These bounds hold for general hash kernels, which we later apply to show how hashing enables us to do large-scale multitask learning efficiently. We start with a simple lemma about the bias and variance of the hash kernel. The proof of this lemma appears in appendix A.

The hash kernel is unbiased, that is Eϕ[⟨x,x′⟩ϕ]=⟨x,x′⟩\mathbf{E}_{\phi}[\left\langle x,x^{\prime}\right\rangle_{\phi}]=\left\langle x,x^{\prime}\right\rangle. Moreover, the variance is σx,x′2=1m(∑i≠jxi2xj′2+xixi′xjxj′)\sigma^{2}_{x,x^{\prime}}=\frac{1}{m}\left(\sum_{i\neq j}x_{i}^{2}{x_{j}^{\prime}}^{2}+x_{i}{x}_{i}^{\prime}x_{j}{x}_{j}^{\prime}\right), and thus, for ∥x∥2=∥x′∥2=1\|x\|_{2}=\|x^{\prime}\|_{2}=1, σx,x′2=O(1m)\sigma_{x,x^{\prime}}^{2}=O\left(\frac{1}{m}\right).

This suggests that typical values of the hash kernel should be concentrated within O(1m)O(\frac{1}{\sqrt{m}}) of the target value. We use Chebyshev’s inequality to show that half of all observations are within a range of 2σ\sqrt{2}\sigma. This, together with an indirect application of Talagrand’s convex distance inequality via the result of (liberty2008dfr), enables us to construct exponential tail bounds.

In this subsection we show that under a hashed feature-map the length of each vector is preserved with high probability. Talagrand’s inequality (Ledoux01) is a key tool for the proof of the following theorem (detailed in the appendix B).

Let ϵ<1\epsilon<1 be a fixed constant and xx be a given instance such that ∥x∥2=1\|x\|_{2}=1. If m≥72log⁡(1/δ)/ϵ2m\geq 72\log(1/\delta)/\epsilon^{2} and ∥x∥∞≤ϵ18log⁡(1/δ)log⁡(m/δ)\|x\|_{\infty}\leq\frac{\epsilon}{18\sqrt{\log(1/\delta)\log(m/\delta)}}, we have that

Note that an analogous result would also hold for the original hash kernel of (Shietal09), the only modification being the associated bias terms. The above result can also be utilized to show a concentration bound on the inner product between two general vectors xx and x′x^{\prime}.

For two vectors xx and x′x^{\prime}, let us define

Also let Δ=∥x∥2+∥x′∥2+∥x−x′∥2\Delta=\left\|x\right\|^{2}+\left\|x^{\prime}\right\|^{2}+\left\|x-x^{\prime}\right\|^{2}. If m≥Ω(1ϵ2log⁡(1/δ))m\geq\Omega(\frac{1}{\epsilon^{2}}\log(1/\delta)) and η=O(ϵlog⁡(m/δ))\eta=O(\frac{\epsilon}{\log(m/\delta)}), then we have that

The proof for this corollary can be found in appendix C. We can also extend the bound in Theorem 3 for the maximal canonical distortion over large sets of distances between vectors as follows:

If m≥Ω(1ϵ2log⁡(n/δ))m\geq\Omega(\frac{1}{\epsilon^{2}}\log(n/\delta)) and η=O(ϵlog⁡(m/δ))\eta=O(\frac{\epsilon}{\log(m/\delta)}). Denote by X={x1,…,xn}X=\left\{x_{1},\ldots,x_{n}\right\} a set of vectors which satisfy ∥xi−xj∥∞≤η∥xi−xj∥2\left\|x_{i}-x_{j}\right\|_{\infty}\leq\eta\left\|x_{i}-x_{j}\right\|_{2} for all pairs i,ji,j. In this case with probability 1−δ1-\delta we have for all i,ji,j

This means that the number of observations nn (or correspondingly the size of the un-hashed kernel matrix) only enters logarithmically in the analysis.

We apply the bound of Theorem 3 to each distance individually. Note that each vector xi−xjx_{i}-x_{j} satisfies the conditions of the theorem, and hence for each vector xi−xjx_{i}-x_{j}, we preserve the distance upto a factor of (1±ϵ)(1\pm\epsilon) with probability 1−δn21-\frac{\delta}{n^{2}}. Taking the union bound over all pairs gives us the result. ∎

2 Multiple Hashing

Note that the tightness of the union bound in Corollary 5 depends crucially on the magnitude of η\eta. In other words, for large values of η\eta, that is, whenever some terms in xx are very large, even a single collision can already lead to significant distortions of the embedding. This issue can be amended by trading off sparsity with variance. A vector of unit length may be written as (1,0,0,0,…)(1,0,0,0,\ldots), or as (12,12,0,…)\left(\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},0,\ldots\right), or more generally as a vector with cc nonzero terms of magnitude c−12c^{-\frac{1}{2}}. This is relevant, for instance whenever the magnitudes of xx follow a known pattern, e.g. when representing documents as bags of words since we may simply hash frequent words several times. The following corollary gives an intuition as to how the confidence bounds scale in terms of the replications:

If we let x′=1c(x,…,x)x^{\prime}=\frac{1}{\sqrt{c}}(x,\ldots,x) then:

It is norm preserving: ∥x∥2=∥x′∥2.\left\|x\right\|_{2}=\left\|x^{\prime}\right\|_{2}.

It reduces component magnitude by 1c=∥x′∥∞∥x∥∞.\frac{1}{\sqrt{c}}=\frac{\left\|x^{\prime}\right\|_{\infty}}{\left\|x\right\|_{\infty}}.

Variance increases to σx′,x′2 ⁣= ⁣1cσx,x2 ⁣+ ⁣c−1c2∥x∥24.\sigma^{2}_{x^{\prime},x^{\prime}}\!=\!\frac{1}{c}\sigma^{2}_{x,x}\!+\!\frac{c-1}{c}2\left\|x\right\|_{2}^{4}.

Applying Lemma 6 to Theorem 3, a large magnitude can be decreased at the cost of an increased variance.

3 Approximate Orthogonality

For multitask learning, we must learn a different parameter vector for each related task. When mapped into the same hash-feature space we want to ensure that there is little interaction between the different parameter vectors. Let UU be a set of different tasks, u∈Uu\in U being a specific one. Let ww be a combination of the parameter vectors of tasks in U∖{u}U\setminus\{u\}. We show that for any observation xx for task uu, the interaction of ww with xx in the hashed feature space is minimal. For each xx, let the image of xx under the hash feature-map for task uu be denoted as ϕu(x)=ϕ(ξ,h)((x,u))\phi_{u}(x)=\phi^{(\xi,h)}((x,u)).

We use Bernstein’s inequality (Bernstein46), which states that for independent random variables XjX_{j}, with E[Xj]=0\mathbf{E}\left[X_{j}\right]=0, if C>0C>0 is such that ∣Xj∣≤C|X_{j}|\leq C, then

We have to compute the concentration property of ⟨w,ϕu(x)⟩=∑jxjξ(j)wh(j)\left\langle w,\phi_{u}(x)\right\rangle=\sum_{j}x_{j}\xi(j)w_{h(j)}. Let Xj=xjξ(j)wh(j)X_{j}=x_{j}\xi(j)w_{h(j)}. By the definition of hh and ξ\xi, XjX_{j} are independent. Also, for each jj, since ww depends only on the hash-functions for U∖{u}U\setminus\{u\}, wh(j)w_{h}(j) is independent of ξ(j)\xi(j). Thus, E[Xj]=E(ξ,h)[xjξ(j)wh(j)]=0\mathbf{E}[X_{j}]=\mathbf{E}_{(\xi,h)}\left[x_{j}\xi(j)w_{h(j)}\right]=0. For each jj, we also have ∣Xj∣<∥x∥∞∥w∥∞=:C|X_{j}|<\left\|x\right\|_{\infty}\left\|w\right\|_{\infty}=:C. Finally, ∑jE[Xj2]\sum_{j}\mathbf{E}[X_{j}^{2}] is given by

The claim follows by plugging both terms and CC into the Bernstein inequality (5). ∎

Theorem 7 bounds the influence of unrelated tasks with any particular instance. In section 5 we demonstrate the real-world applicability with empirical results on a large-scale multi-task learning problem.

Applications

The benefits of the hashing-trick leads to applications in almost all areas of machine learning and beyond. In particular, feature hashing is extremely useful whenever large numbers of parameters with redundancies need to be stored within bounded memory capacity.

One powerful application of feature hashing is found in multitask learning. Theorem 7 allows us to hash multiple classifiers for different tasks into one feature space with little interaction. To illustrate, we explore this setting in the context of spam-classifier personalization.

Suppose we have thousands of users UU and want to perform related but not identical classification tasks for each of the them. Users provide labeled data by marking emails as spam or not-spam. Ideally, for each user u∈Uu\in U, we want to learn a predictor wuw_{u} based on the data of that user solely. However, webmail users are notoriously lazy in labeling emails and even those that do not contribute to the training data expect a working spam filter. Therefore, we also need to learn an additional global predictor w0w_{0} to allow data sharing amongst all users.

Note that in practice the weight vector whw_{h} can be learned directly in the hashed space. All un-hashed weight vectors never need to be computed. Given a new document/email xx of user u∈Uu\in U, the prediction task now consists of calculating ⟨ϕ0(x)+ϕu(x),wh⟩\left\langle\phi_{0}(x)+\phi_{u}(x),w_{h}\right\rangle. Due to hashing we have two sources of error – distortion ϵd\epsilon_{d} of the hashed inner products and the interference with other hashed weight vectors ϵi\epsilon_{i}. More precisely:

The interference error consists of all collisions between ϕ0(x)\phi_{0}(x) or ϕu(x)\phi_{u}(x) with hash functions of other users,

The distortion error occurs because each hash function that is utilized by user uu can self-collide:

To show that ϵd\epsilon_{d} is small with high probability, we apply Corollary 4 once for each possible values of vv.

In section 5 we show experimental results for this setting. The empirical results are stronger than the theoretical bounds derived in this subsection—our technique outperforms a single global classifier on hundreds thousands of users. We discuss an intuitive explanation in section 5.

Massively Multiclass Estimation

We can also regard massively multi-class classification as a multitask problem, and apply feature hashing in a way similar to the personalization setting. Instead of using a different hash function for each user, we use a different hash function for each class.

(Shietal09) apply feature hashing to problems with a high number of categories. They show empirically that joint hashing of the feature vector ϕ(x,y)\phi(x,y) can be efficiently achieved for problems with millions of features and thousands of classes.

Collaborative Filtering

where (h,ξ)(h,\xi) and (h′,ξ′)(h^{\prime},\xi^{\prime}) are independently chosen hash functions. This allows us to approximate matrix elements Mij=[U⊤W]ijM_{ij}=[U^{\top}W]_{ij} via

This gives a compressed vector representation of MM that can be efficiently stored.

Results

We evaluated our algorithm in the setting of personalization. As data set, we used a proprietary email spam-classification task of n=3.2n=3.2 million emails, properly anonymized, collected from ∣U∣=433167|U|=433167 users. Each email is labeled as spam or not-spam by one user in UU. After tokenization, the data set consists of 4040 million unique words.

For all experiments in this paper, we used the Vowpal Wabbit implementationhttp://hunch.net/∼\simvw/ of stochastic gradient descent on a square-loss. In the mail-spam literature the misclassification of not-spam is considered to be much more harmful than misclassification of spam. We therefore follow the convention to set the classification threshold during test time such that exactly 1%1\% of the not−spamnot-spam test data is classified as spamspam Our implementation of the personalized hash functions is illustrated in Figure 1. To obtain a personalized hash function ϕu\phi_{u} for user uu, we concatenate a unique user-id to each word in the email and then hash the newly generated tokens with the same global hash function.

The data set was collected over a span of 14 days. We used the first 10 days for training and the remaining 4 days for testing. As baseline, we chose the purely global classifier trained over all users and hashed into 2262^{26} dimensional space. As 2262^{26} far exceeds the total number of unique words we can regard the baseline to be representative for the classification without hashing. All results are reported as the amount of spam that passed the filter undetected, relative to this baseline (eg. a value of 0.800.80 indicates a 20%20\% reduction in spam for the user)As part of our data sharing agreement, we agreed not to include absolute classification error-rates..

Figure 2 displays the average amount of spam in users’ inboxes as a function of the number of hash keys mm, relative to the baseline above. In addition to the baseline, we evaluate two different settings.

The global-hashed curve represents the relative spam catch-rate of the global classifier after hashing ⟨ϕ0(w0),ϕ0(x)⟩\left\langle\phi_{0}(w_{0}),\phi_{0}(x)\right\rangle. At m=226m=2^{26} this is identical to the baseline. Early convergence at m=222m=2^{22} suggests that at this point hash collisions have no impact on the classification error and the baseline is indeed equivalent to that obtainable without hashing.

In the personalized setting each user u∈Uu\in U gets her own classifier ϕu(wu)\phi_{u}(w_{u}) as well as the global classifier ϕ0(w0)\phi_{0}(w_{0}). Without hashing the feature space explodes, as the cross product of u=400Ku=400K users and n=40Mn=40M tokens results in 1616 trillion possible unique personalized features. Figure 2 shows that despite aggressive hashing, personalization results in a 30%30\% spam reduction once the hash table is indexed by 2222 bits.

One hypothesis for the strong results in Figure 2 might originate from the non-uniform distribution of user votes — it is possible that using personalization and feature hashing we benefit a small number of users who have labeled many emails, degrading the performance of most users (who have labeled few or no emails) in the process. In fact, in real life, a large fraction of email users do not contribute at all to the training corpus and only interact with the classifier during test time. The personalized version of the test email Φu(xu)\Phi_{u}(x_{u}) is then hashed into buckets of other tokens and only adds interference noise ϵi\epsilon_{i} to the classification.

In order to show that we improve the performance of most users, it is therefore important that we not only report averaged results over all emails, but explicitly examine the effects of the personalized classifier for users depending on their contribution to the training set. To this end, we place users into exponentially growing buckets based on their number of training emails and compute the relative reduction of uncaught spam for each bucket individually. Figure 3 shows the results on a per-bucket basis. We do not compare against a purely local approach, with no global component, since for a large fraction of users—those without training data—this approach cannot outperform random guessing.

It might appear rather surprising that users in the bucket with none or very little training emails (the line of bucket isidenticaltobucketis identical to bucket) also benefit from personalization. After all, their personalized classifier was never trained and can only add noise at test-time. The classifier improvement of this bucket can be explained by the subjective definition of spam and not-spam. In the personalized setting the individual component of user labeling is absorbed by the local classifiers and the global classifier represents the common definition of spam and not-spam. In other words, the global part of the personalized classifier obtains better generalization properties, benefiting all users.

Related Work

A number of researchers have tackled related, albeit different problems.

(RahRec08) use Bochner’s theorem and sampling to obtain approximate inner products for Radial Basis Function kernels. (RahRec09) extend this to sparse approximation of weighted combinations of basis functions. This is computationally efficient for many function spaces. Note that the representation is dense.

(LiChuHas07) take a complementary approach: for sparse feature vectors, ϕ(x)\phi(x), they devise a scheme of reducing the number of nonzero terms even further. While this is in principle desirable, it does not resolve the problem of ϕ(x)\phi(x) being high dimensional. More succinctly, it is necessary to express the function in the dual representation rather than expressing ff as a linear function, where ww is unlikely to be compactly represented: f(x)=⟨ϕ(x),w⟩f(x)=\left\langle\phi(x),w\right\rangle.

(Achlioptas03) provides computationally efficient randomization schemes for dimensionality reduction. Instead of performing a dense d⋅md\cdot m dimensional matrix vector multiplication to reduce the dimensionality for a vector of dimensionality dd to one of dimensionality mm, as is required by the algorithm of (GioIndMot99), he only requires 13\frac{1}{3} of that computation by designing a matrix consisting only of entries {−1,0,1}\left\{-1,0,1\right\}. Pioneered by (ailon2006ann), there has been a line of work (ailon2008fdr; matousek2008vjl) on improving the complexity of random projection by using various code-matrices in order to preprocess the input vectors. Some of our theoretical bounds are derivable from that of (liberty2008dfr).

A related construction is the CountMin sketch of (CorMut04) which stores counts in a number of replicates of a hash table. This leads to good concentration inequalities for range and point queries.

(Shietal09) propose a hash kernel to deal with the issue of computational efficiency by a very simple algorithm: high-dimensional vectors are compressed by adding up all coordinates which have the same hash value — one only needs to perform as many calculations as there are nonzero terms in the vector. This is a significant computational saving over locality sensitive hashing (Achlioptas03; GioIndMot99).

Several additional works provide motivation for the investigation of hashing representations. For example, (GanchevDredze08) provide empirical evidence that the hashing trick can be used to effectively reduce the memory footprint on many sparse learning problems by an order of magnitude via removal of the dictionary. Our experimental results validate this, and show that much more radical compression levels are achievable. In addition, (LaLiSt07) released the Vowpal Wabbit fast online learning software which uses a hash representation similar to that discussed here.

Conclusion

In this paper we analyze the hashing-trick for dimensionality reduction theoretically and empirically. As part of our theoretical analysis we introduce unbiased hash functions and provide exponential tail bounds for hash kernels. These give further inside into hash-spaces and explain previously made empirical observations. We also derive that random subspaces of the hashed space are likely to not interact, which makes multitask learning with many tasks possible.

Our empirical results validate this on a real-world application within the context of spam filtering. Here we demonstrate that even with a very large number of tasks and features, all mapped into a joint lower dimensional hash-space, one can obtain impressive classification results with finite memory guarantee.

References

Appendix A Mean and Variance

Since Eϕ[⟨x,x′⟩ϕ]=Eh[Eξ[⟨x,x′⟩ϕ]]\mathbf{E}_{\phi}[\left\langle x,x^{\prime}\right\rangle_{\phi}]=\mathbf{E}_{h}[\mathbf{E}_{\xi}[\left\langle x,x^{\prime}\right\rangle_{\phi}]], taking expectations over ξ\xi we see that only the terms i=ji=j have nonzero value, which shows the first claim. For the variance we compute Eϕ[⟨x,x′⟩ϕ2]\mathbf{E}_{\phi}[\left\langle x,x^{\prime}\right\rangle_{\phi}^{2}]. Expanding this, we get:

This expression can be simplified by noting that:

Passing the expectation over ξ\xi through the sum, this allows us to break down the expansion of the variance into two terms.

by noting that Eh[δh(i),h(j)]=1m\mathbf{E}_{h}\left[\delta_{h(i),h(j)}\right]=\frac{1}{m} for i≠ji\neq j. Using the fact that σ2=Eϕ[⟨x,x′⟩ϕ2]−Eϕ[⟨x,x′⟩ϕ]2\sigma^{2}=\mathbf{E}_{\phi}[\left\langle x,x^{\prime}\right\rangle_{\phi}^{2}]-\mathbf{E}_{\phi}[\left\langle x,x^{\prime}\right\rangle_{\phi}]^{2} proves the claim. ∎

Appendix B Concentration of Measure

We use the concentration result derived by Liberty, Ailon and Singer in (liberty2008dfr). Liberty et al. create a Johnson-Lindenstrauss random projection matrix by combining a carefully constructed deterministic matrix AA with random diagonal matrices. For completeness we restate the relevant lemma. Let ii range over the hash-buckets. Let m=clog⁡(1/δ)/ϵ2m=c\log(1/\delta)/\epsilon^{2} for a large enough constant cc. For a given vector xx, define the diagonal matrix DxD_{x} as (Dx)jj=xj(D_{x})_{jj}=x_{j}. For any matrix A∈ℜm×dA\in\Re^{m\times d}, define ∥x∥A≡max⁡y:∥y∥2=1∥ADxy∥2\|x\|_{A}\equiv\max_{y:\|y\|_{2}=1}\|AD_{x}y\|_{2}.

For any column-normalized matrix AA, vector xx with ∥x∥2=1\|x\|_{2}=1 and an i.i.d. random ±1\pm 1 diagonal matrix DsD_{s}, the following holds: ∀x,\mboxif∥x∥A≤ϵ6log⁡(1/δ)\mboxthen,Pr⁡[∣∥ADsx∥2−1∣>ϵ]≤δ.\forall x,\mbox{ if }\|x\|_{A}\leq\frac{\epsilon}{6\sqrt{\log(1/\delta)}}\mbox{ then, }\Pr[|\|AD_{s}x\|_{2}-1|>\epsilon]\leq\delta.

We also need the following form of a weighted balls and bins inequality – the statement of the Lemma, as well as the proof follows that of Lemma 6 (dsr2010sparse). We still outline the proof because of some parameter values being different.

Let mm be the size of the hash function range and let η=12mlog⁡(m/δ)\eta=\frac{1}{2\sqrt{m\log(m/\delta)}}. If xx is such that ∥x∥2=1\|x\|_{2}=1 and ∥x∥∞≤η\|x\|_{\infty}\leq\eta, then define σ∗2=max⁡i∑j=1dxj2δih(j)\sigma^{2}_{*}=\max_{i}\sum_{j=1}^{d}x_{j}^{2}\delta_{ih(j)} where ii ranges over all hash-buckets. We have that with probability 1−δ1-\delta,

We outline the proof-steps. Since the buckets have identical distribution, we look only at the 1st1^{st} bucket, i.e. at i=1i=1 and bound ∑j:h(j)=1xj2\sum_{j:h(j)=1}x_{j}^{2}. Define Xj=xj2(δ1h(j)−1m)X_{j}=x_{j}^{2}\left(\delta_{1h(j)}-\frac{1}{m}\right). Then Eh[Xj]=0E_{h}[X_{j}]=0 and Eh[Xj2]=xj4(1m−1m2)≤xj4m≤xj2η2mE_{h}[X_{j}^{2}]=x_{j}^{4}\left(\frac{1}{m}-\frac{1}{m^{2}}\right)\leq\frac{x_{j}^{4}}{m}\leq\frac{x_{j}^{2}\eta^{2}}{m} using ∥x∥∞≤η\|x\|_{\infty}\leq\eta. Thus, ∑jEh[Xj2]≤η2m\sum_{j}E_{h}[X_{j}^{2}]\leq\frac{\eta^{2}}{m}. Also note that ∑jXj=∑j:h(j)=1xj2−1m\sum_{j}X_{j}=\sum_{j:h(j)=1}x_{j}^{2}-\frac{1}{m}. Plugging this into the Bernstein’s inequality, equation 5, we have that

By taking union bound over all the mm buckets, we get the above result. ∎

Given the function ϕ=(h,r)\phi=(h,r), define the matrix AA as Aij=δih(j)A_{ij}=\delta_{ih(j)} and DsD_{s} as (Ds)jj=rj(D_{s})_{jj}=r_{j}. Let xx be as specified, i.e. ∥x∥2=1\|x\|_{2}=1 and ∥x∥∞≤η\|x\|_{\infty}\leq\eta. Note that ∥x∥ϕ=∥ADsx∥2\|x\|_{\phi}=\|AD_{s}x\|_{2}. Let y∈ℜdy\in\Re^{d} be such that ∥y∥2=1\|y\|_{2}=1. Thus

by applying the Cauchy-Schwartz inequality, and using the definition of σ∗\sigma_{*}. Thus, ∥x∥A=max⁡y:∥y∥2=1∥ADxy∥2≤σ∗≤2m−1/2\|x\|_{A}=\max_{y:\|y\|_{2}=1}\|AD_{x}y\|_{2}\leq\sigma_{*}\leq\sqrt{2}m^{-1/2}. If m≥72ϵ2log⁡(1/δ)m\geq\frac{72}{\epsilon^{2}}\log(1/\delta), we have that ∥x∥A≤ϵ6log⁡(1/δ)\|x\|_{A}\leq\frac{\epsilon}{6\sqrt{\log(1/\delta)}}, which satisfies the conditions of Lemma 2 from (liberty2008dfr). Thus applying the above result from Lemma 2 (liberty2008dfr) to xx, and using Lemma 8, we have that Pr⁡[∣∥ADsx∥2−1∣≥ϵ]≤δ\Pr[|\|AD_{s}x\|^{2}-1|\geq\epsilon]\leq\delta and hence

by taking union over the two error probabilities of Lemma 2 and Lemma 8, we have the result. ∎

Appendix C Inner Product

We have that 2⟨x,x′⟩ϕ=∥x∥ϕ2+∥x′∥ϕ2−∥x−x′∥ϕ22\left\langle x,x^{\prime}\right\rangle_{\phi}=\left\|x\right\|_{\phi}^{2}+\left\|x^{\prime}\right\|_{\phi}^{2}-\left\|x-x^{\prime}\right\|_{\phi}^{2}. Taking expectations, we have the standard inner product inequality. Thus,

Using union bound, with probability 1−3δ1-3\delta, each of the terms above is bounded using Theorem 3. Thus, putting the bounds together, we have that, with probability 1−3δ1-3\delta,

Appendix D Refutation of the Previous Incorrect Proof

There were a few bugs in the previous version of the paper (weinberger2009fhl). We now detail each of them and illustrate why it was an error. The current result shows that the using hashing we can create a projection matrix that can preserve distances to a factor of (1±ϵ)(1\pm\epsilon) for vectors with a bounded ∥x∥∞/∥x∥2\|x\|_{\infty}/\|x\|_{2} ratio. The constraint on input vectors can be circumvented by multiple hashing, as outlined in Section 3.2, but that would require hashing O(1ϵ2)O(\frac{1}{\epsilon^{2}}) times. Recent work (dsr2010sparse) suggests that better theoretical bounds can be shown for this construction. We thank Tamas Sarlos and Ravi Kumar for the following writeup on the errors and for suggestion the new proof in Appendix B.

The statement of the main theorem in Weinberger et al. (Weinberger et al.,, 2009)Theorem 3]weinberger2009fhl is false as it contradicts the lower bound of Alon (alon2003par). The flaw lies in the probability of error in (Weinberger et al.,, 2009)Theorem 3]weinberger2009fhl, which was claimed to be exp⁡(−ϵ4η)\exp(-\frac{\sqrt{\epsilon}}{4\eta}). This error can be made arbitrarily small without increasing the embedding dimensionality mm but by decreasing η=∣∣x∣∣∞∣∣x∣∣2\eta=\frac{||x||_{\infty}}{||x||_{2}}, which in turn can be achieved by preprocessing the input vectors xx. However, this contradicts Alon’s lower bound on the embedding dimensionality. The details of this contradiction are best presented through (Weinberger et al.,, 2009)Corollary 5]weinberger2009fhl as follows.

Set m=128m=128 and δ=1/2\delta=1/2 and consider the vertices of the nn-simplex in ℜn+1\Re^{n+1}, i.e., x1=(1,0,...,0)x_{1}=(1,0,...,0), x2=(0,1,0,...,0)x_{2}=(0,1,0,...,0), …. Let P∈ℜ(n+1)c×(n+1)P\in\Re^{(n+1)c\times(n+1)} be the naive, replication based preconditioner, with replication parameter c=512log⁡2nc=512\log^{2}n as defined in Section 2 of our submission or (Weinberger et al.,, 2009)Section 3.2]weinberger2009fhl. Therefore for all pairs i≠ji\neq j we have that ∣∣Pxi−Pxj∣∣∞=1/c||Px_{i}-Px_{j}||_{\infty}=1/\sqrt{c} and that ∣∣Pxi−Pxj∣∣2=2||Px_{i}-Px_{j}||_{2}=\sqrt{2}. Hence we can apply (Weinberger et al.,, 2009)Corollary 5]weinberger2009fhl to the set of vectors PxiPx_{i} with η=1/2c=1/(32log⁡n)\eta=1/\sqrt{2c}=1/(32\log n); then the claimed approximation error is 2m+64η2log⁡2n2δ=18+116≤14\sqrt{\frac{2}{m}}+64\eta^{2}\log^{2}\frac{n}{2\delta}=\frac{1}{8}+\frac{1}{16}\leq\frac{1}{4}. If Corollary 5 were true, then it would follow that with probability at least 1/21/2, the linear transformation A=ϕ⋅P:ℜn+1→ℜmA=\phi\cdot P:\Re^{n+1}\rightarrow\Re^{m} distorts the pairwise distances of the above n+1n+1 vectors by at most a 1±1/41\pm 1/4 multiplicative factor. On the other hand, the lower bound of Alon shows that any such transformation AA must map to Ω(log⁡n)\Omega(\log n) dimensions; see the remarks following Theorem 9.3 in (alon2003par) and set ϵ=1/4\epsilon=1/4 there. This clearly contradicts m=128m=128 above.

The proof of the Theorem 3 contained a fatal, unfixable error. Recall that δij\delta_{ij} denotes the usual Kronecker symbol, and hh and h′h^{\prime} are hash functions. Weinberger et al. make the following observation after equation (13) of their proof on page 8 in Appendix B.

“First note that ∑i∑jδh(j)i+δh′(j)i\sum_{i}\sum_{j}\delta_{h(j)i}+\delta_{h^{\prime}(j)i} is at most 2t2t, where t=∣{j:h(j)≠h′(j)}∣t=|\{j:h(j)\neq h^{\prime}(j)\}|.”

The quoted observation is false. Let dd denote the dimension of the input. Then, ∑i∑jδh(j)i+δh′(j)i=∑j(∑iδh(j)i+δh′(j)i)=∑j2=2d\sum_{i}\sum_{j}\delta_{h(j)i}+\delta_{h^{\prime}(j)i}=\sum_{j}(\sum_{i}\delta_{h(j)i}+\delta_{h^{\prime}(j)i})=\sum_{j}2=2d, independent of the choice of the hash function. Note that tt played a crucial role in the proof of (weinberger2009fhl) relating the Euclidean approximation error of the dimensionality reduction to Talagrand’s convex distance defined over the set of hash functions. Albeit the error is elementary, we do not see how to rectify its consequences in (weinberger2009fhl) even if the claim were of the right form.

The proof of Theorem 3 in (weinberger2009fhl) also contains a minor and fixable error. To see this, consider the sentence towards the end of the proof Theorem 3 in (weinberger2009fhl) where 0<ϵ<10<\epsilon<1 and β=β(x)≥1\beta=\beta(x)\geq 1.

“Noting that s2=(β2+ϵ−β)/4∣∣x∣∣∞≥ϵ/4∣∣x∣∣∞s^{2}=(\sqrt{\beta^{2}+\epsilon}-\beta)/4||x||_{\infty}\geq\sqrt{\epsilon}/4||x||_{\infty}, …”

Here the authors wrongly assume that β2+ϵ−β≥ϵ\sqrt{\beta^{2}+\epsilon}-\beta\geq\sqrt{\epsilon} holds, whereas the truth is β2+ϵ−β≤ϵ\sqrt{\beta^{2}+\epsilon}-\beta\leq\sqrt{\epsilon} always.

Observe that this glitch is easy to fix locally, however this change is minor and the modified claim would still be false. Since for all 0≤y≤10\leq y\leq 1 we have that 1+y≥1+y/3\sqrt{1+y}\geq 1+y/3, from β≥1\beta\geq 1 it follows that β2+ϵ−β≥ϵ/3\sqrt{\beta^{2}+\epsilon}-\beta\geq\epsilon/3. Plugging the latter estimate into the “proof” of Theorem 3 would result in a modified claim where the original probability of error, exp⁡(−ϵ4η)\exp(-\frac{\sqrt{\epsilon}}{4\eta}), is replaced with exp⁡(−ϵ12η)\exp(-\frac{\epsilon}{12\eta}). Updating the numeric constants in the first section of this note would show that the new claim still contradicts Alon’s lower bound. To justify observe that counter example is based on a constant ϵ\epsilon and the modified claim would still lack the necessary Ω(log⁡n)\Omega(\log n) dependency in its target dimensionality.