NASH: Toward End-to-End Neural Architecture for Generative Semantic Hashing

Dinghan Shen, Qinliang Su, Paidamoyo Chapfuwa, Wenlin Wang, Guoyin Wang, Lawrence Carin, Ricardo Henao

Introduction

Similarity search—the task of finding documents similar to a query within a massive corpus—is a fundamental challenge in information retrieval. Semantic hashing addresses this by mapping documents to short binary strings, allowing for extremely fast comparisons using Hamming distance on modern hardware.

However, traditional hashing methods often suffer from a "two-stage" disconnect: they learn continuous representations first and then apply ad-hoc binarization as a separate step. This process discards valuable information and leads to suboptimal local optima. NASH (Neural Architecture for Semantic Hashing) bridges this gap by introducing the first end-to-end framework that treats binary hash codes as latent variables within a generative model, jointly optimizing the hash function and a reconstruction task.

Methodology

NASH is built upon the Neural Variational Inference (NVI) framework, allowing the model to learn high-quality binary codes in a single, unified training process.

The architecture consists of several critical components:

  • Encoder (The Hash Function): An MLP takes a document (represented as TF-IDF or Bag-of-Words) and maps it to the parameters of a Bernoulli distribution.
  • Latent Variables: The binary hash codes are treated as stochastic Bernoulli variables. To enable end-to-end training, the authors utilize the Straight-Through (ST) estimator, which allows gradients to "skip" over the non-differentiable binarization step during backpropagation.
  • Decoder (The Generative Component): The model attempts to reconstruct the original document from the binary code. This generative objective forces the code to capture the most important semantic information, acting as a powerful regularizer.
  • Data-Dependent Noise: A key innovation in NASH is the injection of Gaussian noise into the latent codes during training. Crucially, the amount of noise is not fixed; it is predicted from the input document. This connects the model to Rate-Distortion Theory, allowing it to adaptively balance the number of bits used against reconstruction error.

Experimental Evaluation

The model was evaluated on three standard public datasets for document retrieval: Reuters21578 (news documents), 20Newsgroups (forum posts), and TMC (air traffic reports).

Key Insights and Results

A primary finding of the research is that end-to-end training is essential. By training the encoder and decoder together, the model learns a hash function that is specifically "aware" of the eventual binarization. Interestingly, the authors found that a linear decoder often outperformed complex non-linear ones. A linear decoder forces the latent space to be more semantically organized, as it cannot rely on a complex network to "fix" a messy latent representation.

Precision comparison of NASH-DN-S against state-of-the-art hashing methods across different bit lengths.

NASH significantly outperformed previous state-of-the-art models like VDSH (Variational Deep Semantic Hashing) and STH (Self-Taught Hashing). In unsupervised tests on the Reuters dataset with 32-bit codes, NASH achieved a precision of 0.8418, compared to 0.7753 for VDSH. When label information was included (NASH-DN-S), the model consistently outperformed other supervised methods across various bit lengths ranging from 8 to 128 bits.

Qualitative analysis confirmed that the learned codes carry deep semantic meaning. For a query like "weapons," the model successfully associated terms such as "gun," "armed," and "assault" in the embedding space.

Limitations and Future Work

Despite its success, NASH has areas for further refinement. The Straight-Through estimator is computationally efficient but biased; exploring more sophisticated gradient estimators like REBAR or RELAX could improve stability. Additionally, the authors noted that performance can plateau or slightly drop with very long codes (e.g., 128 bits), likely due to data sparsity. Future work could also involve replacing the simple MLP encoder with more modern architectures, such as Transformers, to better capture document structure before hashing.

Summary updated

BibTeX
@inproceedings{shen2018nash,
  author = {Dinghan Shen and Qinliang Su and Paidamoyo Chapfuwa and Wenlin Wang and Guoyin Wang and Lawrence Carin and Ricardo Henao},
  title = {{NASH: Toward End-to-End Neural Architecture for Generative Semantic Hashing}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2018},
  doi = {10.18653/v1/p18-1190},
}
Figure