Skip to main content
QUICK REVIEW

[Paper Review] Hamming OCR: A Locality Sensitive Hashing Neural Network for Scene Text Recognition

Bingcong Li, Xin Tang|arXiv (Cornell University)|Sep 23, 2020
Advanced Image and Video Retrieval TechniquesComputer Science36 references6 citations
TL;DR

Hamming OCR proposes a lightweight scene text recognition model that replaces traditional softmax and embedding layers with a locality-sensitive hashing (LSH)-based Hamming classifier and Hamming embeddings, reducing model size independently of vocabulary size. By using LSH codes for classification and representation, the method achieves competitive accuracy on standard benchmarks and a large Chinese dataset (GBK21K) with only 1.22 MB for the classifier, a 32× reduction over standard softmax.

ABSTRACT

Recently, inspired by Transformer, self-attention-based scene text recognition approaches have achieved outstanding performance. However, we find that the size of model expands rapidly with the lexicon increasing. Specifically, the number of parameters for softmax classification layer and output embedding layer are proportional to the vocabulary size. It hinders the development of a lightweight text recognition model especially applied for Chinese and multiple languages. Thus, we propose a lightweight scene text recognition model named Hamming OCR. In this model, a novel Hamming classifier, which adopts locality sensitive hashing (LSH) algorithm to encode each character, is proposed to replace the softmax regression and the generated LSH code is directly employed to replace the output embedding. We also present a simplified transformer decoder to reduce the number of parameters by removing the feed-forward network and using cross-layer parameter sharing technique. Compared with traditional methods, the number of parameters in both classification and embedding layers is independent on the size of vocabulary, which significantly reduces the storage requirement without loss of accuracy. Experimental results on several datasets, including four public benchmaks and a Chinese text dataset synthesized by SynthText with more than 20,000 characters, shows that Hamming OCR achieves competitive results.

Motivation & Objective

  • To address the high storage cost of softmax and embedding layers in scene text recognition models, especially for large vocabularies like Chinese or multilingual text.
  • To reduce model parameters and storage requirements without sacrificing recognition accuracy in large-scale lexicon scenarios.
  • To design a lightweight transformer decoder by removing feed-forward networks and applying cross-layer parameter sharing.
  • To explore the use of LSH codes as both classifier outputs and character embeddings, enabling efficient, scalable text recognition.

Proposed method

  • Proposes a Hamming classifier that uses locality-sensitive hashing (LSH) to map each character to a binary code in Hamming space, replacing the standard softmax layer.
  • Generates LSH codes via linear projection and thresholding, with a majority voting mechanism to stabilize code representation.
  • Uses the LSH code directly as the output embedding, eliminating the need for a separate embedding matrix and reducing parameters.
  • Introduces a simplified transformer decoder by removing the feed-forward network and applying cross-layer parameter sharing to reduce parameters.
  • Employs MobileNetV2 as the feature encoder for efficient deployment on mobile devices.
  • Trains the model using hinge loss to optimize the LSH projection matrix for accurate classification.

Experimental results

Research questions

  • RQ1Can LSH-based Hamming codes effectively replace traditional softmax and embedding layers in scene text recognition while maintaining accuracy?
  • RQ2How does the performance of LSH codes compare to random binary codes in large-vocabulary settings like Chinese text recognition?
  • RQ3What is the optimal length of LSH codes for balancing model performance and size in scene text recognition?
  • RQ4To what extent can parameter reduction be achieved in the classifier and embedding layers using LSH codes instead of dense matrices?
  • RQ5How effective is the simplified transformer decoder with shared parameters and removed feed-forward networks in maintaining recognition accuracy?

Key findings

  • The Hamming OCR model achieves 82.41% accuracy on the GBK21K dataset with over 20,000 characters, significantly outperforming random binary codes, which failed to converge.
  • The LSH-based classifier requires only 1.22 MB of storage, a 32× reduction compared to the 39.1 MB needed for a standard softmax layer with a 512-dimensional feature space and 20,000-class vocabulary.
  • The model with 512-bit LSH codes achieves the best performance on GBK21K, with 82.39% accuracy, and performance saturates beyond 512 bits.
  • Random binary codes achieve 84.54% accuracy on SVT but fail entirely on GBK21K, demonstrating the necessity of structured LSH codes for large vocabularies.
  • The simplified transformer decoder with cross-layer parameter sharing and removed feed-forward networks reduces model parameters while maintaining competitive performance.
  • The Hamming OCR model achieves state-of-the-art results on four public benchmarks and a large-scale Chinese dataset, proving its effectiveness and efficiency for large-vocabulary text recognition.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.