Abstract
This study investigates the utility of non-contextual BERT embeddings as a computationally efficient middle ground between full contextual models and traditional static embeddings like FastText. Focusing on the low-resource language Marathi, we compare embeddings extracted from BERT's initial layer against standard FastText across multiple classification tasks. Our findings demonstrate that while contextual BERT remains the performance leader, non-contextual BERT embeddings serve as a superior static alternative, provided their high-dimensional structure is preserved.
Introduction
In Natural Language Processing (NLP), contextual models like BERT have become the gold standard due to their ability to capture word meaning based on surrounding text. However, these models require a full forward pass through multiple transformer layers, which is computationally expensive for real-time applications or resource-constrained environments. For low-resource languages (LRLs) like Marathi, researchers often default to non-contextual embeddings like FastText, which function as simple, fast lookup tables but lack the deep linguistic knowledge of BERT.
This paper addresses whether the first embedding layer of BERT can be used as a high-performance static lookup table, bypassing expensive transformer computations while retaining the benefits of BERT's massive pre-training.
Methodology
The researchers evaluated three primary embedding strategies:
- Contextual BERT: The output of the final hidden layer, requiring a full model inference.
- Non-Contextual BERT: The output of the initial embedding layer, used as a static lookup table.
- FastText: Traditional subword-based static embeddings.
To ensure a fair comparison, the authors addressed dimensionality differences. BERT typically utilizes 768-dimensional vectors, whereas FastText uses 300. The study employed Singular Value Decomposition (SVD) to compress BERT embeddings down to 300 dimensions to test if BERT's superiority was merely a function of higher dimensionality.
For the downstream classification tasks, a simple Multiple Logistic Regression (MLR) classifier was used. This choice isolates the performance of the embeddings themselves, ensuring that results are not skewed by the complexity of the neural network head.
Datasets and Experimental Setup
The analysis focused on Marathi using three benchmark datasets:
- MahaSent: A 3-class sentiment analysis dataset.
- MahaHate: Hate speech detection (2-class and 4-class).
- MahaNews: News categorization across headlines (SHC), long documents (LDC), and long paragraphs (LPC).
Models evaluated included language-specific variants like MahaBERT and MahaFT, alongside multilingual models such as MuRIL and IndicFT.
Key Results and Insights
- Contextual Superiority: As hypothesized, full contextual BERT (MahaBERT) achieved the highest performance, reaching 93.87% accuracy on the MahaNews LDC task.
- The Non-Contextual Advantage: Non-contextual BERT embeddings consistently outperformed FastText when kept at their native dimensionality. For instance, in 4-class hate speech detection, non-contextual MahaBERT achieved 66.5% accuracy compared to MahaFT’s 62.75%.
- The Impact of Compression: Applying SVD to BERT embeddings resulted in a significant performance drop, often falling below FastText levels. This suggests that BERT’s linguistic knowledge is distributed across its high-dimensional space; linear compression techniques like SVD destroy the nuances that provide its competitive edge.
- Efficiency Gains: Non-contextual BERT offers a "middle path," providing higher accuracy than FastText while maintaining the same inference speed by ignoring the 12+ transformer layers above the embedding base.
Conclusion and Future Work
Non-contextual BERT embeddings represent a viable strategy for high-performance NLP in resource-constrained settings. They provide a significant upgrade over traditional static embeddings like FastText without the overhead of full transformer inference.
Future research should explore non-linear compression or distillation techniques that might better preserve BERT's performance at lower dimensions. Additionally, extending this comparative framework to other Indic languages will help determine if the "BERT-as-a-lookup-table" strategy is a universal recommendation for low-resource linguistic contexts.
Summary updated