Neural Machine Translation via Binary Code Prediction

Yusuke Oda, Philip Arthur, Graham Neubig, Koichiro Yoshino, Satoshi Nakamura

Abstract

In this paper, we propose a new method for calculating the output layer in neural machine translation (NMT) systems. The method is based on predicting a binary code for each word and can reduce computation time and memory requirements of the output layer to be logarithmic in vocabulary size in the best case. In addition, we also introduce two advanced approaches to improve the robustness of the proposed model: using error-correcting codes and combining softmax and binary codes. Experiments on two English-Japanese bidirectional translation tasks show proposed models achieve BLEU scores that approach the softmax, while reducing memory usage to the order of less than 1/10 and improving decoding speed on CPUs by 5x to 10x.

Introduction: The Softmax Bottleneck

Neural Machine Translation has become the standard for high-quality automated translation. However, standard NMT architectures face a significant computational hurdle known as the "softmax bottleneck." In a typical model, the final output layer uses a softmax function to calculate a probability distribution across the entire vocabulary.

Standard NMT architecture with a conventional softmax output layer, illustrating the linear complexity relative to vocabulary size.

If the vocabulary $V$ contains 60,000 words, the model must calculate 60,000 scores for every single token generated. This results in $O(V)$ linear complexity, which creates three primary issues:

  1. Memory Usage: Storing the weight matrix for a massive vocabulary requires significant VRAM or RAM.
  2. Inference Latency: Calculating large vectors is slow, particularly on CPUs or edge devices.
  3. Scalability: As vocabularies grow to support open-domain translation, the linear cost becomes prohibitive.

Proposed Method: Binary Code Prediction

To address these challenges, we propose Binary Code Prediction. Instead of selecting one word out of $V$ candidates, the model predicts a bit-string (e.g., 16 bits for a 65k vocabulary) where each bit is predicted independently. This shifts the complexity from $O(V)$ to $O(\log V)$.

Hybrid Softmax/Binary Model

Recognizing that frequent words are easier for the model to learn and rare words are more numerous, we introduce a hybrid approach. The model uses a standard softmax for the $N$ most frequent tokens and a "binary branch" for the remaining rare tokens. This ensures high precision for common words while maintaining efficiency for the long tail of the vocabulary.

The proposed hybrid architecture combining a small softmax for frequent tokens and a sigmoid-based binary prediction for rare tokens.

Error-Correcting Codes (ECC)

Raw binary prediction is inherently brittle; a single bit flip results in an entirely different word. To improve robustness, we treat the neural network's output as a "noisy signal" and apply classical information theory. By using convolutional codes and Viterbi decoding, we add redundancy to the bit-strings. This allows the system to recover the correct word even if individual bit predictions are imperfect.

Experimental Evaluation

We evaluated the approach on the ASPEC (Asian Scientific Paper Excerpt Corpus) and BTEC (Basic Travel Expression Corpus) datasets for English-Japanese translation.

Key Results

  • Translation Quality: The best-performing model, Hybrid-2048-EC, achieved BLEU scores comparable to the full softmax baseline. On the BTEC task, it slightly outperformed the standard softmax (48.17 vs 47.72 BLEU), likely due to better generalization on rare words.
  • Efficiency: Output layer parameters were reduced to less than 1/10th of the original size.
  • Speedup: CPU decoding speed improved by 5x to 10x. In the ASPEC task, latency per sentence dropped from approximately 2539ms to 201ms.
  • Training Performance: Training times for mini-batches decreased by 15-25% compared to standard softmax models.

Conclusion

By moving from linear to logarithmic scaling in the output layer, binary code prediction offers a viable path for deploying high-quality NMT on resource-constrained devices. The combination of hybrid modeling and error-correcting codes mitigates the traditional accuracy trade-offs associated with compressed output layers. Future work will explore learning optimal codes automatically during training and applying similar binary representations to the input embedding layer to further reduce the total model footprint.

Summary updated

BibTeX
@inproceedings{oda2017neural,
  author = {Yusuke Oda and Philip Arthur and Graham Neubig and Koichiro Yoshino and Satoshi Nakamura},
  title = {{Neural Machine Translation via Binary Code Prediction}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2017},
  url = {https://openreview.net/forum?id=SkZ6snldWB},
}
Figure