Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Spectral Hashing

Spectral hashing builds short binary codes from analytic eigenfunctions of a data distribution

  • Problem Retrieving similar images from millions of items needs short binary codes, but random projections such as E2LSH need many bits to find good neighbors. Learned codes from RBMs and boosting have bits that depend heavily on each other.
  • Method Spectral hashing relaxes the balanced, uncorrelated bit problem and assumes the data is drawn from a distribution. It fits a rectangle along PCA axes and thresholds the smallest analytic eigenfunctions, so a new point is encoded without a nearest-neighbor search.
  • Results On a 2D rectangle, spectral hashing beat LSH, RBMs and Boosting SSC in the authors' experiments.

Why retrieval at scale needs better codes

Searching millions of stored images for the neighbors of a query is hard unless each item is kept as a short binary code. Semantic hashing takes this route, giving similar items similar codewords and retrieving items within a small Hamming distance of the query code. Storing millions of images in memory and finding similar ones quickly are the two challenges this approach has to solve.

Even with such an embedding, simply having Euclidean distance does not give a fast retrieval mechanism.

The classic way to build such codes is E2LSH, which thresholds random linear projections, so the Hamming distance approaches the Euclidean distance only asymptotically. Learned codes do better, and the autoencoder with 32 hidden units in its middle layer gave far more compact codes than E2LSH. Boosting with decision stumps also beat E2LSH on the toy data, though it stayed slightly behind the RBM codes.

Yet the bits learned by RBMs and boosting can depend heavily on each other, which the authors see as a weakness. The authors therefore ask what the best code for a given dataset is, and whether that code can be computed in closed form. Because of this link, even a single bit leads to an NP hard problem of finding optimal codes. Their answer is a spectral relaxation whose bits come from thresholding a subset of Laplacian eigenvectors.

What a good code must satisfy

A good code needs three properties: it must be cheap to compute for a novel input, short for the whole dataset, and faithful to similarity. The authors set aside the cheap-encoding requirement at first and look only for codes that are short and keep similar points close. Their starting point is an embedding in Euclidean space where Euclidean distance correlates with the desired similarity.

Random projections with thresholds, as in E2LSH, make similar items map to similar codewords but can need many bits.

The affinity is W(i,j) = exp(-||xi - xj||^2 / epsilon^2), so epsilon sets the distance in Rd that counts as similar. The average Hamming distance between similar neighbors is written as the sum of Wij times the squared norm of yi minus yj. Each codeword yi lies in {-1, 1}^k, and the code must be efficient, so each bit fires 50% of the time.

The sum of the yi equal to zero forces each bit to fire half the time. The identity constraint, one over n times the sum of yi yi transpose equal to I, keeps the bits uncorrelated. Relaxing full independence to uncorrelated bits gives the minimization problem in equation (1).

For a single bit, the objective is the total weight of the edges cut between the two halves of the data. Requiring the two halves to be equal turns the problem into balanced graph partitioning. Balanced graph partitioning is NP hard, so even one bit is hard to optimize. With k bits, the task becomes finding k independent balanced partitions, each with as small a cut as possible.

The authors use this graph view to motivate the spectral relaxation that follows.

Relaxing to eigenvectors and extending to new points

Dropping the {-1, 1} constraint turns the hard code problem into an eigenvector problem on the graph Laplacian. Stacking the codewords into an n by k matrix Y, the objective becomes trace(Y^T(D - W)Y), with D the diagonal degree matrix. Once the entries of Y can be any real values, the solutions are the k eigenvectors of D - W with minimal eigenvalue.

The trivial eigenvector 1, which has eigenvalue 0, is excluded from that set.

Thresholding these eigenvectors would only code the items in the training set, so a new point needs an out-of-sample extension. With millions of items in the dataset, the authors call this impractical, since the Nystrom extension is as expensive as exhaustive nearest neighbor search.

To avoid this cost, the authors assume the datapoints x_i in R^d are samples from a probability distribution p(x). They replace the sample averages in problem 1 with expectations, which gives the continuous problem 3 with W(x1, x2) = e^{-||x1-x2||^2/eps^2}. Relaxing the constraint that y(x) is in {-1, 1}^k then gives a spectral problem whose solutions are eigenfunctions of a weighted Laplace-Beltrami type operator L_p.

The eigenvectors of the discrete Laplacian built from n points sampled from p(x) converge to these eigenfunctions as n goes to infinity. Because the eigenfunctions are defined for every x, a new point can be encoded without a search over the dataset. The next question is which distributions give eigenfunctions in closed form, and the authors start with separable distributions.

Why separable distributions give closed-form eigenfunctions

A separable density, such as a uniform distribution over a box, makes the eigenfunctions of L_p take a product form. A multidimensional Gaussian also qualifies, once the space is rotated so that its axes are aligned. In one dimension, a uniform distribution on [a, b] has sine eigenfunctions, and their eigenvalues depend on the frequency and the interval length.

The paper calls these one-dimensional eigenfunctions extremely well studied, since they match the modes of vibration of a metallic plate.

The eigenvalues depend on the aspect ratio of the rectangle and on the spatial frequency, so long axes get cut before short ones. Low spatial frequencies are preferred, so they come first in the ordering. The radius ϵ changes the eigenvalues but not their ordering, so the choice of similarity radius doesn't change which eigenfunctions are picked.

The eigenfunctions don't depend on ϵ at all, which is why the same bits come out for any neighbourhood size.

Multiplying one-dimensional eigenfunctions across axes gives outer-product eigenfunctions in d dimensions, with eigenvalues equal to the product of the one-dimensional eigenvalues. The sign of a product is the product of the signs, so a bit built from an outer-product eigenfunction is a deterministic function of the other bits. The authors therefore keep the single-dimension eigenfunctions and drop the outer-product ones.

Such bits are approximately uncorrelated, but the authors stress that they are not independent.

Because the relaxation only enforced uncorrelated bits, the outer-product bits slip through the constraint while still being dependent. Fitting a multidimensional rectangle after PCA alignment, with a uniform distribution on each axis, works well for a wide range of distributions.

Running the spectral hashing algorithm

Training starts with PCA, which aligns the coordinate axes with the principal directions of the data. A uniform rectangle is then fitted along each PCA axis, which the authors treat as a crude model of the data.

For each of the d axes, the analytic eigenvalues are computed for each frequency, giving d times k candidates. Sorting these candidates keeps the k smallest, and each kept eigenfunction defines one bit. Each selected eigenfunction is thresholded at zero to give a binary bit. The eigenvalue ordering favors cutting the long dimension first, so the selection favors long axes.

A new point is projected onto the same PCA axes and passed through the same closed-form functions. This avoids the nearest-neighbor search over the training set that the Nystrom method requires. The authors note that the Nystrom extension costs as much as exhaustive nearest neighbor search, which is impractical for millions of items.

The authors also tried multidimensional Gaussians and frequencies that are powers of two. They report that neither variant gave a significant improvement, so the simple version drives the results. Spectral hashing with this simple rectangle model outperforms the other methods in the synthetic experiments.

Synthetic comparisons against LSH, RBMs and boosting

On the 2D rectangle in Figure 4a, spectral hashing beats LSH, RBMs and Boosting SSC in the authors' experiments. Spectral hashing wins with bits that come from analytic eigenfunctions rather than from learned weights. Applying RBMs or Boosting to the spectral hashing output doesn't improve its performance. So an extra learning stage stacked on the spectral bits adds nothing in this experiment.

The authors trace the gap to the partitions each bit defines on the data. LSH uses random linear partitions, which may give very unbalanced partitions. Spectral hashing targets balanced and approximately independent cuts, which the authors use to explain its win. Figure 3 shows Hamming balls for 3, 7 and 15 bits, with radius 1 in green and radius 2 in blue.

On the 10 dimensional uniform distribution in Figure 4b, the paper reports a similar pattern of results. On the toy dataset in Figure 1, E2LSH average precision at Hamming distance 1 rises as the number of bits grows. That E2LSH convergence is slow, so many bits are needed for good performance. RBM codes perform much better than random bits in the same toy setting.

Boosting SSC also beats E2LSH, though it is slightly worse than the RBMs. Boosting SSC uses adaBoost to classify pairs of items as similar or nonsimilar, with decision stumps as weak learners.

LabelMe and the 80 million image set

Spectral hashing is tested on the LabelMe dataset, where the data is far from uniformly distributed. The authors fit a simple N dimensional rectangle to this data, even though it is a poor model of the database statistics. Spectral hashing still retrieves better than boosting, which actually uses the distribution of the data. Figure 5 plots the proportion of good neighbors against the number of bits for LSH, boosting, RBM and spectral hashing.

The gap between spectral hashing and RBMs isn't significant, according to the authors.

With a small number of bits, the authors check the retrieved neighbors by eye. They judge that the images retrieved by spectral hashing look better than those retrieved by boosting. This is a visual judgement, and the paper doesn't report a measured score for it.

Torralba et al. collected 80 million images, and the authors test retrieval over that set. Figure 6 shows these results, and the authors call this dataset obviously more challenging than LabelMe. Even with exhaustive search, some retrieved neighbors are semantically quite different. Still, most retrieved neighbors seem semantically relevant when the codes use 64 bits.

Retrieval with these 64 bit spectral hashing codes takes fractions of a second.

On real images, the evidence comes from the LabelMe comparison plot and visual checks on the larger set.

Limits of the rectangle model

The method assumes that a multidimensional uniform distribution generated the data, and the authors call this its first limitation. Spectral hashing uses a rectangle model that the paper calls a terrible model of the database statistics on LabelMe. Even so, the rectangle beats boosting, which actually uses the distribution, on that dataset.

The data on LabelMe is certainly not uniformly distributed, yet spectral hashing still gives better retrieval than boosting and LSH.

The authors fit a rectangle after PCA alignment and found that the codes stay robust to the exact form of the distribution. They tested multidimensional Gaussians as an alternative to the uniform assumption. Neither variant gave a significant improvement in their experiments.

The power-of-two frequency variant was the authors' attempt to reduce these dependencies, and it didn't yield a significant gain. The paper's analysis says that the cost of the Nystrom extension grows linearly with the dataset size. For millions of items, the authors state that this cost is as expensive as exhaustive nearest neighbor search.

The paper gives this cost argument as analysis only, and it doesn't report a timing comparison against the Nystrom method.

Paper info

Authors
Weiss, Yair, Torralba, Antonio, Fergus, Rob
Venue
Advances in Neural Information Processing Systems · Published
Added
2026-11-12
Original paper terms
Check in the original ↗
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Weiss, Yair, Torralba, Antonio, Fergus, Rob (2008). Spectral Hashing. Advances in Neural Information Processing Systems. https://papers.nips.cc/paper/2008/hash/d58072be2820e8682c0a27c0518e805e-Abstract.html

BibTeX
@article{yair2008spectral,
  title = {{Spectral Hashing}},
  author = {Weiss, Yair and Torralba, Antonio and Fergus, Rob},
  year = {2008},
  journal = {Advances in Neural Information Processing Systems},
  url = {https://papers.nips.cc/paper/2008/hash/d58072be2820e8682c0a27c0518e805e-Abstract.html}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up