betaFeedback

WorksComputer Science

One-Bit Estimators via the Balanced Fast Johnson-Lindenstrauss Transform

Abstract

Vector databases and near-duplicate detectors compress high-dimensional vectors for rapid query comparison. One-bit sketches retain only the signs of random projections, estimating inner products either by correlating a sign code against a full-precision query (the asymmetric estimator) or by comparing two sign codes directly (SimHash). Existing guarantees rely on dense Gaussian projections, whose cost dominates encoding in high dimensions. The fast Johnson-Lindenstrauss transform (FJLT) offers a fast alternative: after a randomized Hadamard transform spreads coordinate energy, a sparse Gaussian matrix with roughly rr nonzeros per row replaces the dense projection. Signing an FJLT output is the natural fast one-bit sketch, yet has lacked theoretical guarantees. We prove nonasymptotic bounds for both the classical FJLT and a balanced variant with exactly rr nonzeros per row, equalizing workloads, simplifying vectorization, and reducing variance in captured energy. Conditioned on its support, a sparse Gaussian row remains an exact Gaussian projection, viewing data through a randomly distorted metric. Taking signs turns this distortion into a systematic bias that adding rows cannot average away. We bound this bias by an explicit constant times w/rw/r, where the cap ww measures peak coordinate energy after preconditioning. Thus, O(ε−2log⁡(N/δ))O(\varepsilon^{-2}\log(N/δ)) rows with O(ε−1log⁡(nN/δ))O(\varepsilon^{-1}\log(nN/δ)) nonzeros per row estimate NN cosine similarities in Rn\mathbb{R}^n to accuracy ε\varepsilon with probability 1−δ1-δ: one-bit quantization increases row density rather than sketch length. Matching lower bounds show the ε−1\varepsilon^{-1} sparsity factor is unavoidable for the asymmetric estimator at small ε\varepsilon, while at full precision we recover the optimal sparsity of the linear FJLT with explicit constants.

Introduction

Modern information retrieval and machine learning systems routinely store massive collections of high-dimensional vectors and compare them against incoming queries. Vector databases index embeddings of documents and images, near-duplicate detectors maintain fingerprints of web pages, and large language models cache the attention keys of past tokens. Because memory bandwidth and capacity are scarce in all of these applications, stored vectors must be heavily compressed. The central question is how accurately inner products with new queries can be recovered from the compressed representations.

One-bit sketches are among the simplest and most effective compression schemes. By multiplying a vector by a random Gaussian matrix with ℓ\ell rows and retaining only the signs of the resulting entries, a vector is reduced to an ℓ\ell-bit signature alongside its Euclidean norm. These sign codes are used in two main ways. Symmetric schemes such as SimHash compare two bit strings by the fraction of positions at which they disagree, which directly estimates the angle between the underlying vectors [8]. Asymmetric schemes quantize only the stored vector to one bit and correlate its sign code against a query kept at higher precision. For instance, QJL compresses attention keys in this manner [36]—a primitive subsequently reused by TurboQuant [37]—while RaBitQ scores the sign codes of randomly rotated database vectors against quantized queries [15].

Throughout this paper, we label each estimator by the precision kept on either side—one bit (B) or a full-precision Gaussian projection (G)—listing the stored vector first. Thus BB denotes SimHash, BG denotes the asymmetric estimator, and GG denotes the standard linear sketch with full precision on both sides, which serves as our baseline. Because vector norms are stored separately, inner product estimation reduces to estimating the cosine of the angle between two vectors, and we state all results for unit vectors. When constructed from a dense Gaussian matrix, all three estimators require only a small constant multiple of ε−2log⁡(N/δ)\varepsilon^{-2}\log(N/\delta) rows to estimate the cosines of NN vector pairs to within additive error ε\varepsilon with probability at least 1−δ1-\delta, regardless of the geometry of the data.

The computational bottleneck of dense sketching lies in the projection step itself. Multiplying a vector in Rn\mathbb{R}^{n} by a dense ℓ×n\ell\times n matrix requires nℓn\ell multiply–add operations, whereas scoring two compressed codes takes only O(ℓ)O(\ell) operations. Encoding a single vector is therefore as expensive as performing nn pairwise comparisons, and because ℓ\ell scales as ε−2\varepsilon^{-2}, this encoding cost grows rapidly when high accuracy is required. For linear sketches, Ailon and Chazelle [ [3] overcame this bottleneck by introducing the fast Johnson–Lindenstrauss transform (FJLT). The FJLT first flips the signs of the vector’s coordinates at random and then applies the normalized Walsh–Hadamard transform, an orthogonal map computable in nlog⁡2nn\log_{2}n additions. Together, these two operations spread the energy ∥x∥2\lVert x\rVert^{2} of any fixed vector xx almost uniformly across all nn coordinates. Once no single coordinate dominates, sampling a small number of coordinates at random captures a representative share of the vector’s energy, allowing a sparse Gaussian matrix with roughly r≪nr \ll n nonzeros per row to stand in for a dense one. The resulting transform Φ=PHD\Phi= PHD—where DD is a diagonal matrix of random signs, HH is the normalized Hadamard matrix, and PP is a sparse Gaussian matrix—reduces the encoding cost from nℓn\ell to nlog⁡2n+rℓn\log_{2}n+r\ell operations, saving roughly a factor of n/rn/r for long sketches. We refer to ℓ\ell as the sketch length and rr as the row sparsity.

Taking the signs of an FJLT projection is the natural way to accelerate one-bit sketching. Although Oymak and Recht [ [30], Sec. 7 observed empirically that signing a moderately sparse Gaussian projection performs nearly as well as signing a dense one, no nonsasymptotic theoretical guarantees have been established. There is a fundamental reason for this gap: the Euclidean guarantees of the FJLT rely crucially on linearity, which the sign function destroys. Once linearity is lost, sparse rows become much less forgiving. Indeed, the ℓ1\ell_{1} variant of the FJLT analyzed by Ailon and Chazelle [ [3] already incurs an extra factor of ε−1\varepsilon^{-1} in row density, for reasons closely related to the phenomenon we examine in § 1.1.

In this work, we provide the missing theoretical guarantees for fast one-bit sketches. We establish nonsasymptotic error bounds with explicit constants for both the asymmetric (BG) and symmetric (BB) estimators, covering both the original FJLT and a balanced variant in which every row has exactly rr nonzeros. Crucially, our bounds hold conditionally on the realized preconditioner DD and depend on the dataset only through a few easily measurable summary statistics, allowing practitioners to certify the accuracy of a deployed sketch directly on their data. In the worst case, our results reveal a clean trade-off: quantization to one bit costs row sparsity rather than sketch length. Up to a small constant factor, the required sketch length ℓ\ell matches that of a dense Gaussian sketch, whereas the required number of nonzeros per row rr scales as 1/ε1/\varepsilon. Complementary lower bounds confirm that for small ε\varepsilon, the asymmetric estimator cannot achieve accuracy ε\varepsilon with o(1/ε)o(1/\varepsilon) sparse rows.

Why signs are harder

Both the core difficulty of signing sparse projections and the mechanism that resolves it can be understood by examining a single row. Fix the random coordinate signs DD, and let x~=HDx\tilde{x}=HDx denote the preconditioned image of a vector xx; because HDHD is orthogonal, two unit vectors uu and vv with ⟨u,v⟩=ρ=cos⁡θ\langle u,v\rangle=\rho=\cos\theta map to unit vectors u~\tilde{u} and v~\tilde{v} with the same inner product ρ\rho and angle θ\theta. A row of the sparse matrix PP is nonzero only on a random subset of coordinates, its support SS, where its entries are independent N(0,1/q)\mathcal{N}(0,1/q) random variables and q=r/nq=r/n is the sampling density.

Now condition on the support SS as well. Absorbing the q−1/2q^{-1/2} variance scaling into the vector by defining the subsampled vector x~S∈Rn\tilde{x}_{S}\in\mathbb{R}^{n} with coordinates (x~S)j:=q−1/2x~j1{j∈S}(\tilde{x}_{S})_{j}:=q^{-1/2}\tilde{x}_{j}\mathbf{1}\{j\in S\}, a sparse row acts on (u,v)(u,v) identically in distribution to a standard isotropic Gaussian vector g∼N(0,In)g\sim\mathcal{N}(0,I_{n}) acting on (u~S,v~S)(\tilde{u}_{S},\tilde{v}_{S}). Consequently, the scalar row projections XX and YY remain jointly centered Gaussian given SS, just as they would be for a dense row, and only their covariance matrix changes: whereas a dense row has covariance (1ρρ1)\begin{pmatrix}1 & \rho\\ \rho& 1\end{pmatrix}, a sparse row with support SS has conditional covariance

ΣS:=(σu2σuvσuvσv2)=(∥u~S∥2⟨u~S,v~S⟩⟨u~S,v~S⟩∥v~S∥2).\Sigma_S := \begin{pmatrix}\sigma_u^2 & \sigma_{uv} \\ \sigma_{uv} & \sigma_v^2\end{pmatrix} = \begin{pmatrix}\lVert\widetilde{u}_S\rVert^2 & \langle\widetilde{u}_S,\widetilde{v}_S\rangle\\ \langle\widetilde{u}_S,\widetilde{v}_S\rangle& \lVert\widetilde{v}_S\rVert^2\end{pmatrix}.

Here σu2\sigma_u^2 and σv2\sigma_v^2 are the rescaled energies that the row captures from uu and vv, and σuv\sigma_{uv} is their captured inner product. Over the random draw of SS, all three entries match their dense counterparts in expectation (Eσu2=Eσv2=1\mathbb{E}\sigma_u^2=\mathbb{E}\sigma_v^2=1 and Eσuv=ρ\mathbb{E}\sigma_{uv}=\rho), yet each fluctuates from row to row.

Figure 1 illustrates this effect in the two-dimensional plane spanned by uu and vv. Coordinate subsampling maps the unit circle of the plane onto an ellipse that varies from row to row, sending (u~,v~)(\widetilde{u},\widetilde{v}) to (u~S,v~S)(\widetilde{u}_S,\widetilde{v}_S) with squared norms σu2,σv2\sigma_u^2,\sigma_v^2 and inner product σuv\sigma_{uv}. Equivalently, each sparse row measures lengths and angles in span⁡{u,v}\operatorname{span}\{u,v\} using a random positive semidefinite 2×22\times2 matrix MSM_S in place of the Euclidean identity I2I_2; we call MSM_S the random metric induced by the row, and its expectation over SS is I2I_2 (§ 3.2).

Figure 1. Conditioned on its support SS, a sparse row views the pair (u,v)(u,v) through the subsampled pair (u~S,v~S)(\widetilde{u}_S,\widetilde{v}_S); among the three geometric features read by the estimators, only the inner product is unbiased across supports. Left: a dense row sees (u~,v~)(\widetilde{u},\widetilde{v}) on the Euclidean unit circle. Right: given SS, coordinate subsampling deforms the unit circle of span⁡{u,v}\operatorname{span}\{u,v\} (dashed) into an ellipse. The linear estimator GG reads σuv=⟨u~S,v~S⟩\sigma_{uv}=\langle\widetilde{u}_S,\widetilde{v}_S\rangle, the asymmetric estimator BG reads the scalar projection ζS=σuv/σu\zeta_S=\sigma_{uv}/\sigma_u of v~S\widetilde{v}_S onto the direction of u~S\widetilde{u}_S, and SimHash (BB) reads the angle θS\theta_S.

The three estimators extract three different geometric features from (u~S,v~S)(\widetilde{u}_S,\widetilde{v}_S). Each estimator averages a per-row score across the ℓ\ell rows: GG averages the product XYXY, BG averages Z:=π/2 sign⁡(X)YZ:=\sqrt{\pi/2}\,\operatorname{sign}(X)Y, and BB averages the indicator 1{sign⁡X≠sign⁡Y}\mathbf{1}\{\operatorname{sign}X\ne\operatorname{sign}Y\}. Conditioned on SS, applying the classical dense Gaussian identities (§ 2.1) directly to (u~S,v~S)(\widetilde{u}_S,\widetilde{v}_S) yields the conditional expectation of each score:

E[XY∣S]=σuv,E[Z∣S]=σuvσu=:ζS,Pr⁡[sign⁡X≠sign⁡Y∣S]=θSπ,\mathbb{E}[XY\mid S]=\sigma_{uv},\qquad\mathbb{E}[Z\mid S]=\frac{\sigma_{uv}}{\sigma_u}=:\zeta_S,\qquad\Pr[\operatorname{sign}X\ne\operatorname{sign}Y\mid S]=\frac{\theta_S}{\pi},

where θS=∠(u~S,v~S)\theta_S=\angle(\widetilde{u}_S,\widetilde{v}_S) satisfies cos⁡θS=ρS:=σuv/(σuσv)\cos\theta_S=\rho_S:=\sigma_{uv}/(\sigma_u\sigma_v). Notice the sharp divide between the linear and one-bit estimators: GG reads the inner product σuv\sigma_{uv}, which is a linear functional of MSM_S. Because EMS=I2\mathbb{E}M_S=I_2, GG is completely unbiased at every sparsity level; sparse rows merely inflate its variance. By contrast, BG reads an inner product normalized by a length (σuv/σu)(\sigma_{uv}/\sigma_u), and BB reads an angle (θS)(\theta_S). Because neither functional is linear in MSM_S, Jensen’s inequality and higher-order curvature convert random metric fluctuations into a systematic second-order shift in expectation, which we call the support bias. Because every row is drawn from the same support distribution, averaging over more rows reduces the sampling variance but leaves the support bias intact; only increasing the row sparsity rr, which dampens the metric distortion itself, can make this bias small.

References

  1. [1]Dimitris Achlioptas. Database-friendly random projections: Johnson–Lindenstrauss with binary coins. Journal of Computer and System Sciences, 66(4):671–687, 2003.DOI
  2. [2]Albert Ai, Alex Lapanowski, Yaniv Plan, and Roman Vershynin. One-bit compressed sensing with non-Gaussian measurements. Linear Algebra and its Applications, 441:222–239, 2014. doi: 10.1016/j.laa.2013.04.002.DOI
  3. [3]Nir Ailon and Bernard Chazelle. The fast Johnson–Lindenstrauss transform and approximate nearest neighbors. SIAM Journal on Computing, 39(1):302–322, 2009.
  4. [4]Peter J. Bickel. One-step Huber estimates in the linear model. Journal of the American Statistical Association, 70(350):428–434, 1975.DOI
  5. [5]Stéphane Boucheron, Gábor Lugosi, and Pascal Massart. Concentration Inequalities: A Nonasymptotic Theory of Independence. Oxford University Press, 2013.
  6. [6]Olivier Catoni. Challenging the empirical mean and empirical variance: A deviation study. Annales de l’Institut Henri Poincaré, Probabilités et Statistiques, 48(4):1148–1185, 2012. doi: 10.1214/11-AIHP454.DOI
  7. [7]Olivier Catoni and Ilaria Giulini. Dimension-free PAC-Bayesian bounds for matrices, vectors, and linear least squares regression, 2017. arXiv:1712.02747.arxiv.org/abs/1712.02747
  8. [8]Moses Charikar. Similarity estimation techniques from rounding algorithms. In Proceedings of the 34th Annual ACM Symposium on Theory of Computing (STOC), pages 380–388, 2002.
  9. [9]Anna Choromanska, Krzysztof Choromanski, Mariusz Bojarski, Tony Jebara, Sanjiv Kumar, and Yann LeCun. Binary embeddings with structured hashed projections. In Proceedings of the 33rd International Conference on Machine Learning (ICML), volume 48 of Proceedings of Machine Learning Research, pages 344–353, 2016. arXiv:1511.05212.arxiv.org/abs/1511.05212
  10. [10]Sanjoy Dasgupta and Anupam Gupta. An elementary proof of a theorem of Johnson and Lindenstrauss. Random Structures & Algorithms, 22(1):60–65, 2003. doi: 10.1002/rsa.10073.DOI
  11. [11]Sjoerd Dirksen and Alexander Stollenwerk. Fast binary embeddings with Gaussian circulant matrices: Improved bounds. Discrete & Computational Geometry, 60(3):599–626, 2018. arXiv:1608.06498.arxiv.org/abs/1608.06498
  12. [12]Punit Pankaj Dubey, Bhisham Dev Verma, Rameshwar Pratap, and Keegan Kang. Improving sign-random-projection via count sketch. In Proceedings of the 38th Conference on Uncertainty in Artificial Intelligence (UAI), volume 180 of Proceedings of Machine Learning Research, pages 599–609, 2022.
  13. [13]Ora Nova Fandina, Mikael Møller Høgsgaard, and Kasper Green Larsen. The fast Johnson–Lindenstrauss transform is even faster. In Proceedings of the 40th International Conference on Machine Learning (ICML), volume 202 of Proceedings of Machine Learning Research, pages 9689–9715, 2023.arxiv.org/abs/2204.01800
  14. [14]Casper Benjamin Freksen and Kasper Green Larsen. On using Toeplitz and circulant matrices for Johnson–Lindenstrauss transforms. Algorithmica, 82:338–354, 2020.
  15. [15]Jianyong Gao and Cheng Long. RaBitQ: Quantizing high-dimensional vectors with a theoretical error bound for approximate nearest neighbor search. Proceedings of the ACM on Management of Data, 2(3):167:1–167:27, 2024. doi: 10.1145/3654970.DOI
  16. [16]Michel X. Goemans and David P. Williamson. Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming. Journal of the ACM, 42(6):1115–1145, 1995.DOI
  17. [17]David Gross and Vincent Nesme. Note on sampling without replacing from a finite collection of matrices, 2010. arXiv:1001.2738.arxiv.org/abs/1001.2738
  18. [18]Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301):13–30, 1963.
  19. [19]Laurent Jacques, Jason N. Laska, Petros T. Boufounos, and Richard G. Baraniuk. Robust 1-bit compressive sensing via binary stable embeddings of sparse vectors. IEEE Transactions on Information Theory, 59(4):2082–2102, 2013. doi: 10.1109/TIT.2012.2248323.arxiv.org/abs/1104.3160
  20. [20]William B. Johnson and Joram Lindenstrauss. Extensions of Lipschitz mappings into a Hilbert space. In Conference in Modern Analysis and Probability (New Haven, Conn., 1982), volume 26 of Contemporary Mathematics, pages 189–206. American Mathematical Society, Providence, RI, 1984. doi: 10.1090/conm/026/737400.DOI
  21. [21]Daniel M. Kane and Jelani Nelson. Sparser Johnson–Lindenstrauss transforms. Journal of the ACM, 61(1): 4:1–4:23, 2014.
  22. [22]Christopher Kennedy and Rachel Ward. Fast cross-polytope locality-sensitive hashing. In Proceedings of the 8th Innovations in Theoretical Computer Science Conference (ITCS), volume 67 of Leibniz International Proceedings in Informatics (LIPIcs), pages 53:1–53:16, 2017. doi: 10.4230/LIPIcs.ITCS.2017.53. arXiv:1602.06922.DOI
  23. [23]Saehoon Kim and Seungjin Choi. Sparse circulant binary embedding: An asymptotic analysis. IEEE Signal Processing Letters, 25(3):432–436, 2018. doi: 10.1109/LSP.2018.2794768.DOI
  24. [24]Ping Li. Sign-full random projections. In Proceedings of the 33rd AAAI Conference on Artificial Intelligence, volume 33, pages 4205–4212, 2019. arXiv:1805.00533.arxiv.org/abs/1805.00533
  25. [25]Ping Li, Trevor J. Hastie, and Kenneth W. Church. Very sparse random projections. In Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), pages 287–296, 2006.DOI
  26. [26]Jiří Matoušek. On variants of the Johnson–Lindenstrauss lemma. Random Structures & Algorithms, 33(2): 142–156, 2008. doi: 10.1002/rsa.20218.DOI
  27. [27]Andreas Maurer. A bound on the deviation probability for sums of non-negative random variables. Journal of Inequalities in Pure and Applied Mathematics, 4(1):Article 15, 2003.
  28. [28]Stanislav Minsker. Sub-Gaussian estimators of the mean of a random matrix with heavy-tailed entries. The Annals of Statistics, 46(6A):2871–2903, 2018. doi: 10.1214/17-AOS1642.
  29. [29]Jelani Nelson and Huy L. Nguyễn. OSNAP: Faster numerical linear algebra algorithms via sparser subspace embeddings. In Proceedings of the 54th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 117–126, 2013.
  30. [30]Samet Oymak and Benjamin Recht. Near-optimal bounds for binary embeddings of arbitrary sets, 2015. arXiv:1512.04433.
  31. [31]Pedro M. R. Pereira, Felipe A. P. de Figueiredo, and Rausley A. A. de Souza. Fast-TurboQuant: A multiplier-free online vector quantization approach, 2026. arXiv:2606.21448.
  32. [32]Joel A. Tropp. User-friendly tail bounds for sums of random matrices. Foundations of Computational Mathematics, 12(4):389–434, 2012.
  33. [33]Paweł Wolff. On randomness reduction in the Johnson–Lindenstrauss lemma, 2012. arXiv:1202.5500.
  34. [34]Xinyang Yi, Constantine Caramanis, and Eric Price. Binary embedding: Fundamental limits and fast algorithm. In Proceedings of the 32nd International Conference on Machine Learning (ICML), volume 37 of Proceedings of Machine Learning Research, pages 2162–2170, 2015.
  35. [35]Felix X. Yu, Sanjiv Kumar, Yunchao Gong, and Shih-Fu Chang. Circulant binary embedding. In Proceedings of the 31st International Conference on Machine Learning (ICML), volume 32 of Proceedings of Machine Learning Research, pages 946–954, 2014.arxiv.org/abs/1405.3162
  36. [36]Amir Zandieh, Majid Daliri, and Insu Han. QJL: 1-bit quantized JL transform for KV cache quantization with zero overhead, 2024. arXiv:2406.03482v2.
  37. [37]Amir Zandieh, Majid Daliri, Majid Hadian, and Vahab Mirrokni. TurboQuant: Online vector quantization with near-optimal distortion rate. In Proceedings of the 14th International Conference on Learning Representations (ICLR), 2026. arXiv:2504.19874.
  38. [38]Jinjie Zhang and Rayan Saab. Faster binary embeddings for preserving Euclidean distances. In Proceedings of the 9th International Conference on Learning Representations (ICLR), 2021. arXiv:2010.00712.

Paper details

vlnc:W_uabpb7ve
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents