Introduction
Semantic parsing is a critical component of modern voice assistants, responsible for translating natural language queries into structured, actionable commands. While large-scale Transformer models like BERT and RoBERTa have set new benchmarks for accuracy in this domain, their substantial memory requirements pose a significant barrier to deployment on edge devices such as smart speakers and mobile phones. A primary contributor to this memory overhead is the embedding table—a massive matrix storing unique vectors for every token in the vocabulary. This paper presents a novel approach to mitigate this issue by employing compositional code embeddings to drastically reduce the memory footprint of these models without compromising their performance.
Methodology: Compositional Code Embeddings
The core innovation lies in replacing the standard, monolithic embedding table with a more efficient representation. Instead of storing a high-dimensional vector for every word, the authors utilize a technique called Compositional Code Embeddings:
- Codebooks: The model maintains $M$ small codebooks, each containing $K$ basis vectors.
- Discrete Codes: Each vocabulary item is mapped to a set of indices, one for each codebook.
- Composition: The final embedding for a token is generated by summing the vectors retrieved from the codebooks based on its assigned codes.
This method is particularly effective because it can be combined with existing compression techniques. The researchers applied it to already-optimized models like DistilBERT (distillation) and ALBERT (parameter sharing), demonstrating that compositional codes provide complementary benefits. The training process involves an initial "offline" phase where codebooks are trained to reconstruct pretrained embeddings via Mean Squared Error (MSE), followed by task-specific fine-tuning of the entire Transformer architecture.
Experimental Setup
The proposed method was evaluated across three standard task-oriented semantic parsing benchmarks:
- ATIS (Airline Travel Information System): A classic dataset for flight-related queries.
- SNIPS: A popular public dataset for intent detection and slot filling.
- Facebook TOP (Task Oriented Parsing): A complex dataset featuring hierarchical representations with nested intents and slots.
Key Results and Analysis
The experimental results highlight a remarkable efficiency in memory usage. The embedding layers were compressed by 95.15% to 98.46% across various BERT variants. This translated to an overall reduction in encoder size of 20.47% to 34.22%.
Crucially, this compression does not come at the cost of "intelligence." On the SNIPS dataset, the compressed ALBERT-large model (54MB) retained 99.6% of the Exact Match (EM) performance of the state-of-the-art Joint BERT model, which is nearly eight times larger (420MB).
The study also revealed that the Transformer layers are remarkably robust to the "lossy" nature of the reconstructed embeddings. Even when the initial reconstruction isn't a perfect match to the original vectors, the subsequent fine-tuning phase allows the model to adapt and maintain high accuracy. The synergy with ALBERT was particularly noteworthy; despite ALBERT's existing factorized embeddings, compositional codes managed to shrink the model even further, with the compressed ALBERT-base reaching a mere 31MB.
Conclusion and Future Directions
This research demonstrates that standard embedding layers in Transformer models are highly redundant. By utilizing compositional code embeddings, it is possible to achieve significant memory savings while preserving the accuracy required for complex semantic parsing tasks.
While the results are promising for task-oriented parsing, future work could investigate the applicability of this technique to broader natural language processing tasks such as machine translation. Additionally, exploring the integration of compositional code learning directly into the initial pretraining phase, rather than as an offline post-processing step, could further streamline the development of efficient, edge-ready language models.
Summary updated